We have a (poorly written) application scheduling feature in our application that is presenting some interesting issues. A resource's availability is persisted in our database as follows:
Date | Availability
11/30/2008 | XXXXXXXXXXXXXXXXXXXXAAAAAA
AAAXXXXXAA
AAAAAAAAAA
AXXXXXXXAA
AAAAAAAAAA
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
12/01/2008 | XXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXAAA
AAAAAAAAAA
AXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXA
AAAAAAAAAA
12/04/2008 | XXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXAAAA
AAAAAAAAAA
AXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
.... etc.
There's an ID field so we know which resource the "Availability" string applies to. Here's the basic thought process behind how this thing works:
-- Each resource has an availability string on dates when he / she is available. If no record is found for a resource on a given date, the resource is not available at all that day
-- The "Availability" string is 96 characters, each representing a 15-minute increment of the day. Accordingly, the first character shows the resource's availability between 00:00 and 00:15, and the last character shows the resource's availability between 23:45 and 00:00 of the following day.
I'm looking for a way to quickly / efficiently be able to select resources that are available for a given date or date range at a given time or time range. For example, "Show me all resources available between 6:00 AM and 8:00 AM for the week of 12/13 through 12/20."
Obviously, this very strange way of persisting availability makes this quite a challenge.
I'm looking for efficient, creative ways to solve that problem -- high level ideas or concepts are welcome... Not necessarily looking for someone to do all the work for me -- just to recommend some ideas that I may not have thought of.
The application is classic ASP, so I could do this using ASP after the availability strings are found for the requested date range(s), but I'm thinking that perhaps there's a better way to do this using T-SQL ?
Thank you in advance for any assistance.
Regards,
Phil / peh803