I've got a bunch of banners that I want to schedule during different times every year, but I'm having trouble figuring out the sql query for fetching the correct banners. Every banner has a column for "start_date" and one for "end_date" and the rows could look like this:
Code:
start_date | end_date
-------------------------
2000-01-01 | NULL
2000-10-01 | 2000-05-01
2000-05-01 | 2000-01-01
The year is irrelevant here, since these banners should be recurring during certain periods, every year.
The first row has no end date, so that should always be active
The second row (October 1st - May 1st) should not be active
The third row (May 1st - January 1st) should be active
I don't have the sql knowledge to put this logic into a query though, and I was hoping to get some pointers from the experts here. I've fooled around with CASE statements that involved different sets of conditions depending on whether the start month was larger or smaller than the end month, but I never got anywhere.
Thanks very much in advance for any help you can give me!