There is an existing question that asked how to find how many minutes there are in multiple date ranges, ignoring overlaps.
The example data given is (userID isn\'t
I solved that (well, in a way) very efficiently by creating a dumb table having the date and time (accurate be the minute) in one column (PK) and a bit in the second. A '1' meant, the user is available and 0 meant, he/she's not.
The rest is dead simple. I was sick of having to write endless complicated queries in trying to get the minutes in partly overlapping time ranges.
In fact, this was for computing machine efficiency.
I know this is not the real deal but the most simple solution I came up with. You might create a function/SP which creates that table..