Avatar of Nico2011
Nico2011
Flag 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 :-)
Microsoft SQL Server 2008ASP

Avatar of undefined
Last Comment
Nico2011

8/22/2022 - Mon
SOLUTION
Scott Fell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Ephraim Wangoya

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23