I have 2 MySQL tables, ‘scheduled_time’ and ‘appointments’
‘scheduled_time’ has 2 DateTime fields, ‘start’ and ‘end’ – this is a time range of when I am available for appointments.
‘appointments’ contains appointment details but also a ‘start’ and ‘end’ field, this will ultimately be within the range specified in ‘scheduled_time’.
What is the best way for me to find empty time blocks when taking into account both tables?
Lets say I have ‘scheduled_time’ starting 11/9/2010 from 8am to 2pm. and I have one ‘appointment’ from 8am to 10am and one from 1pm to 2pm. How can I find the next available block of say 1 hour?
I did this a while ago. We had a similar structure:
What I did was basically this (steps):