SunQuest
           MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old June 18th, 2004, 09:40 AM
Peat Peat is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 Peat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 )
------------------------------------------------------------

Reply With Quote
  #2  
Old June 19th, 2004, 04:24 PM
lucasalexander lucasalexander is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Atlanta
Posts: 39 lucasalexander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to lucasalexander Send a message via MSN to lucasalexander
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Help With Setting Up A Date (Start and End) Based Booking Query...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway