I have a table "Holidays" in my database, that contains a range of days when it's the holidays, defined with two column: start & end.
Holidays (id, name, start, end)
Now, if I have in input, two dates (from & to), I'd like to list all the dates that are not in the holidays.
Suppose the holidays are from 2012/06/05 to 2012/06/20, and I request:
- from=2012/06/01, to=2012/06/10 ; The result would be 01, 02, 03, 04
- from=2012/06/01, to=2012/06/22 ; The result would be 01, 02, 03, 04, 21, 22
- from=2012/06/15, to=2012/06/22 ; The result would be 21, 22
But I can't figure out how to get this list of "opened" days without hitting the database for every days requested in the range from->to.
How could I do that?