Jkash
Programmer
- Jan 1, 2007
- 6
Hi Guys,
I am working on a booking system in Sql Server Express the query is quite complex. Say the date range searched is from 01/12/06 to the 08/12/06.
The query must show loans that start or end within the search range and also loans that extend through that period for example a loan starts on 23/11/06 to 23/12/06.
I can’t figure it out this is what I have so far:
SELECT booking.bookingID, booking.customerID, CONVERT(varchar, booking.startDate, 103) AS startD, CONVERT(varchar, booking.returnDate, 103) AS returnD,
vehicle.registration
FROM booking INNER JOIN
vehicle ON booking.vehicleID = vehicle.vehicleID
WHERE ( (booking.startDate <= @startDate) AND (booking.returnDate <= @returnDate)) OR
((booking.startDate <= @startDate) AND (booking.returnDate <= @returnDate))OR
( (booking.startDate <= @returnDate) AND (booking.returnDate >= @returnDate)) OR
( (booking.startDate <= @startDate) AND (booking.returnDate >= @returnDate))
Thanks in advance for your help.
I am working on a booking system in Sql Server Express the query is quite complex. Say the date range searched is from 01/12/06 to the 08/12/06.
The query must show loans that start or end within the search range and also loans that extend through that period for example a loan starts on 23/11/06 to 23/12/06.
I can’t figure it out this is what I have so far:
SELECT booking.bookingID, booking.customerID, CONVERT(varchar, booking.startDate, 103) AS startD, CONVERT(varchar, booking.returnDate, 103) AS returnD,
vehicle.registration
FROM booking INNER JOIN
vehicle ON booking.vehicleID = vehicle.vehicleID
WHERE ( (booking.startDate <= @startDate) AND (booking.returnDate <= @returnDate)) OR
((booking.startDate <= @startDate) AND (booking.returnDate <= @returnDate))OR
( (booking.startDate <= @returnDate) AND (booking.returnDate >= @returnDate)) OR
( (booking.startDate <= @startDate) AND (booking.returnDate >= @returnDate))
Thanks in advance for your help.