I have a table that contains scheduled cases with the following basic fields:
BeginTime (DT)
EndTime (DT)
RoomID (int)
Table Name is Meetings
A record is placed in the meetings table every time a case is scheduled. I need to create a sp that when passed a parameters (time need, and DateTime1, DateTime2) will return a result set where there is a big enough gap between other cases or following existing cases.
Example Existing Records
begintime endtime roomID
01/25/2002 07:00 01/25/2002 09:00 1
01/25/2002 09:00 01/25/2002 10:15 1
01/25/2002 13:00 01/25/2002 14:00 1
If I need to time a 1hour slot, I should be able to return at least two options
10:16 - 11:16, 14:01-15:01.
I figure I will need three parameters. The first the the time needed in minutes, the second & third are the date/time range I want to search from.
It seems I should be able to datediff and dateadd functions to do this, but so far I just end up confusing myself.
Any help greatly appreciated.