I have a problem with a scheduling system that has one table with 2 date columns.
Very similar to the problem outlined in this question:
mysql-find-free-time-slots-between-appointments
CREATE TABLE bookings
(`id` int, `StartDate` datetime, `EndDate` datetime, `set_id` int);
INSERT INTO bookings
(`id`, `StartDate`, `EndDate`, `set_id`)
VALUES
(1, '2013-11-20 08:59:00', '2013-11-20 09:00:00', 6),
(2, '2013-11-20 09:00:00', '2013-11-20 09:30:00', 6),
(3, '2013-11-20 09:40:00', '2013-11-20 10:00:00', 6),
(4, '2013-11-20 10:20:00', '2013-11-20 10:30:00', 6),
(5, '2013-11-20 16:20:00', '2013-11-20 16:50:00', 6),
(6, '2013-11-20 22:00:00', '2013-11-20 22:01:00', 6)
Based on an interval of X minutes (say 10 for the example), I want to find the next 5 start times available for an appointment within the date ranges in the table that can be used to add new appointments. It must also be able to look ahead up to 3 months for available slots.
But in my scenario I would need it to return....
| AVAILABLE_FROM |
-----------------------
| 2013-11-20 09:30:00 |
| 2013-11-20 10:00:00 |
| 2013-11-20 10:10:00 |
| 2013-11-20 10:30:00 |
| 2013-11-20 10:40:00 |
If anyone can help with this problem I would be very grateful.
Regards
SlapMe