Link to home
Start Free TrialLog in
Avatar of Nico2011
Nico2011Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Search MS SQL DB for available dates

Hello Experts,

I'm working on a booking engine and would like to know if anyone knows the best way to search a db for availability.  For example, a customer could search for July 1st 2012 +/-7 days, for a 7 day stay, so the query needs to check that there is no booking, either between the June 24th to July 1st, or June 25th to July 2nd, or June 26th to July 3rd etc., right up to July 7th to July 14th.

My DB at the moment has start and end dates, but I'm simply not sure of the best way to do this...!

Please help!  Thanks :-)
SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nico2011

ASKER

Both work - thank you.  Ewangoya's solution is easier for me to implement as the tables already exist and showed me how to avoid the 'collisions'... all help much appreciated!