Timestamp Reference

I’m trying to query a database to get all references to a particular range of dates, if somebody books a time slot all other timeslots should be altered to not allow booking.

If I use the following script for ‘X’ then ‘Y’ gets removed but if I use the script for ‘Y’ then ‘X’ doesn’t get called because the timestamps are out of the script.
Each booking has a start date and end date.

SELECT * FROM bookings WHERE bref=‘$van’ AND ((bookingstart BETWEEN start AND end) OR (bookingend BETWEEN start AND end));

I need to associate all possible crossovers with each booking.

you don’t need to alter anything to indicate unavailable, just make sure you don’t have an overlap when looking for the desired range

there are several threads in this forum that go into this topic – check out the sql in Checking a number from a range, contained within a range under SQL - #4 by r937

run the query to find overlaps, and if it comes up empty, then your applicatyion logic can go ahead and book the desired range

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.