|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Help With Setting Up A Date (Start and End) Based Booking Query...
Hi,
New to the forum, but long time reader. I'm trying to build a script that searches and shows all available projectors that can be rented out from a specific time period. In this case, someone wants to rent out a projector from June 8th to June 10th... There's three projectors, with multiple date entries for all of them...Now when I run this query, it spits out the two Projectors that are booked for this period... Instinctively when I change it to ------------ @sd not between...and @ed not between --------------------------------- ...it displays all the booking results that don't conflict with the dates (20+), when I'd rather it display the projectors where ALL the bookings don't conflict with the queried dates. Any help is VERY MUCH appreciated. Thanks! KR ------------------------------------------------------------ Declare @sd varchar(15); Declare @ed varchar(15); set @sd = '2004-06-08' set @ed = '2004-06-10' SELECT Projector.ProjectorName FROM projectorrequests LEFT OUTER JOIN Projector ON projectorrequests.Projector = Projector.ProjectID WHERE ( @sd between projectorrequests.StartDate and projectorrequests.EndDate or @ed between projectorrequests.StartDate and projectorrequests.EndDate ) ------------------------------------------------------------ |
|
#2
|
|||
|
|||
|
I'm having trouble visualizing your data in my head, but you could select the projectors that are booked into a temporary table, and then you could select the names of any projectors that aren't in the temp table, which should do what you want.
__________________
Lucas Alexander http://www.alexanderdevelopment.net |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Help With Setting Up A Date (Start and End) Based Booking Query... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|