Calculate open timeslots given availability and existing appointments - by day
- by Andre
Overview:
I have a table which stores a persons "availability" for a current day, e.g.
Mon - 8:00am - 11:30am
Mon - 1:30pm - 6:00pm
A second table stores appointments that this person already has for the same day, e.g.
Mon - 8:30am - 11:00am
Mon - 2:30pm - 4pm
Desired result:
Doing calculationsI'd like to have the following result - e.g. "this person has availability on the given day":
Mon - 8:00am - 8:30am
Mon - 11:00am - 11:30am
Mon - 1:30pm - 2:30pm
Mon - 4:00pm - 6:00pm
Any ideas on how to calculate the output given the two inputs (e.g. availability, existing appointments) would be greatly appreciated. Preferably I'd use javascript on the client to do the calculating as I would believe that doing it within the DB (I'm using MSSQL) would be slow for many records, persons, etc.
Hope this is enough information to illustrate the problem at hand - Many thanks in advance.