0

i have a little problem in sql query, i want to display some events which are in between two given (start and end) dates, i did better to retrieve events between dates like,

SELECT event_id, event_name
FROM events
WHERE start_date >= 2013-07-16 AND end_date <= 2013-07-30

but i am facing problem to retrieve events ,

1=> those are starts before my start_date and ends before my end_date

2=> those are starts before my end_date and ends after my end_date

3=> those starts before my start_date and ends after my end_date

All these three lies in between these dates, i am confused about the query, please help!

Irfan Ahmed
  • 8,845
  • 7
  • 32
  • 53
  • Possible duplicate of [Determine Whether Two Date Ranges Overlap](https://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap) – Clockwork-Muse Oct 06 '17 at 21:29

1 Answers1

2

It is simple really:

SELECT event_id, event_name
FROM events
WHERE start_date <= 2013-07-30 AND end_date >= 2013-07-16

(Note that I flipped the dates)

Bart Friederichs
  • 32,037
  • 14
  • 96
  • 185