I have two columns (both datetime) of startDate and endDate in the event table. I get the current day using the date() php function.
This leads to the example of 2013-03-12.
Now there are three event possibilities combined with the dates that occur today:
- The event begins and ends on this day.
- The event started earlier and ends today.
- The event starts today, but ends in the future (> = 2013-03-13)
Now I would like to break these all down into separate queries, since I'm not used to working with dates. I started with the first request, but I already failed on this. I tried the following:
SELECT * FROM events WHERE (startDate= '2013-03-12' AND endDate= '2013-03-12')
and:
SELECT * FROM events WHERE NOT (startDate < '2013-03-12' OR endDate > '2013-03-12')
I also tried to use date() and format dates like "2013-03-12%".
I do not know why this does not work, although I am sure that there is at least one event that occurs on the 12th. Any help is appreciated.
Gooey source share