I have a tbl_availability that determines when a resource is available. The table structure is:
id - running id
startdate - when this availability starts
enddate - when this availability ends
dayofweek - weekday of availability
fromtime - start time
totime - end time
There can be multiple records for the same dayofweek, for example one record for Sundays 1000-1200 and another record for Sundays 1300-1400.
I am trying to figure out how to get two things:
- Check when entering a new record that there is no conflict (overlap) with an existing record
- Given a startdate and enddate, find all of the available periods that apply.