Re: Help with a query please

From: andrewst <member14183_at_dbforums.com>
Date: Wed, 23 Apr 2003 09:21:09 +0000
Message-ID: <2796477.1051089669_at_dbforums.com>


Originally posted by John
> How can i check whether a user is already booked for a given period? I
> have tried the following query but this only checks for a booking that
> starts before the gaiven date and ends after it
>
> SELECT B.*
> FROM WMS_User U, WMS_Bookings B
> WHERE B.User_ID = '1'
> AND B.Booking_Start_Date >= '2003-04-28'
> AND B.Booking_End_Date <= '2003-04-29'
>
> if a user is booked from 2003-04-29 to 2003-05-01 then the query
> returns no
> rows...
>
If you want any bookings that overlap the date range at all, do this:

AND B.Booking_End_Date >= '2003-04-28'
AND B.Booking_Start_Date <= '2003-04-29'

--
Posted via http://dbforums.com
Received on Wed Apr 23 2003 - 11:21:09 CEST

Original text of this message