I am designing an online booking application, that requires me to check wheather the slot selected by the user is available or not and i wrote the following store procedure.... Main idea behind is to check if the date slot overlaps with any other slot already booked.
if the value in counter is > 0 it means the slot is not available.....
create procedure spcheckbookings
@categoryid as integer,
@equipmentid as integer,
@dateto as datetime,
@dateend as datetime
Select count(*) as Counter
(dateto = @dateto and dateend = @dateend)
(dateto > @dateto and dateend > @dateend and @dateto < dateend)
(dateto < @dateto and dateend < @dateend and dateend > @dateto)
But the date comparisons does not give me right results for some reasons, and when we compare dates are time compared as well is
13-06-2006 10:12 > 13-06-2006 09:12
As i need to get this working too.
Any help much appreciated.