Logic for retrieving earliest available start date
I am doing some work for a charity who have a series of rooms available for hire.
Each room can be hired in increments of 1 hour from 9am until 5pm. When they receive a booking, the start time and end time are stored in a simple bookings table.
In order to populate the drop downs that allow the user to select their booking time, I need to get the earliest possible start time. So if there are no bookings it starts at 9am. But if there is a 9am-11am booking then it starts at 11am. But if ther is also a 11am-1pm booking then it will need to start at 1pm. Equally, if there is also a booking from 4pm-5pm then it should stop at 4pm.
I just need the earliest possible start time and the latest possible finish time, which I can then use to add all of the valid values to my drop downs.
I hope I explained the problem clearly. Any help would be greatly appreciated.