I have two date field in a table.
Start and End

I need to run a query to find out which records in a period.

For example,
in database have two date fields (event_start and event_end)

I want to find out all activities include in 13/8 to 15/9.

Not use between. Because some event maybe began on 10/9 but end date is over 15/9. So use between can not find out accurately.

How can I do?

Recommended Answers

All 3 Replies

try like this

select * from table_name where ( event_start between 13/8/11 and 15/9/11 )
and (event_end  between 13/8/11 and 15/9/11)

I think that should be an OR not an AND between the two bracketed conditions.

Nope, debasisdas has it correct. If you want all events that started AND ended between a certain period you need to use AND.
OP states it

Not use between. Because some event maybe began on 10/9 but end date is over 15/9. So use between can not find out accurately.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.