In my db bookings are periods with SSTART and SEND fields as period start and end dates. How to find free periods from booking table but free periods within some time window - free booking periods from e.g. '2012-07-01' til '2012-07-31'. On site http://www.artfulsoftware.com/infotree/queries.php#577 one can find how to find free periods but I don't know how to define time window.
Asked
Active
Viewed 108 times
1
-
1It's generally easier to do this in one's application code: query to obtain booked periods during the desired range and then infer that any date not in the resultset is free. If you *must* do this within SQL, you would need to construct a table of all dates in which you're interested and outer join against that: this can be done with a `UNION` subquery or with a dedicated (temporary?) table – eggyal Jun 10 '12 at 05:41