Reputation: 123
I have a mySQL table named events with 4 fields (event_id, event_name, event_start_date, event_end_date)
The problem is retrieving the correct events
I would get the record for all the active events in a time period for example between 2011/03/01 to 2011/03/30
All events are active during the considered time period and should be retrieved as records
I have no idea how to make it work correctly! Solutions? Suggestions? Ideas?
Thanks
Upvotes: 4
Views: 10222
Reputation: 837986
Try this:
SELECT
event_id,
event_name,
event_start_date,
event_end_date
FROM events
WHERE event_start_date <= '2011-03-30'
AND event_end_date >= '2011-03-01'
Upvotes: 2
Reputation: 44921
Assuming @Start and @End hold the date range you are looking for:
SELECT * FROM Events
-- Exclude items known to be outside the range
WHERE NOT ((event_end_date < @Start) OR (event_start_date > @End))
Upvotes: 3
Reputation: 3905
Select * From temp where mydate >= '2011-03-10' and mydate =< '2011-03-20';
and so on
Upvotes: 0