Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex Query Help
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00611652
Message ID:
00611705
Views:
30
That one returns the cases scheduled that don't exceed the datetime2 parameter. Here is what I have been working on:
select t1.roomid,
	dateadd(mi,1,t1.EndTime) as StartOfGap,
	dateadd(mi,1,t1.BeginTime) as EndOfGap,
	datediff(mi,t1.EndTime,t2.BeginTime) as LengthOfGap
from meetings T1 join Meetings T2 on (t1.roomID=t2.RoomID)
where (dateadd(mi,1,t1.EndTime) =
	(Select Max(dateadd(mi,1,t3.endtime))
	  from meetings T3
	  where (t3.roomID=T1.RoomID)
	  And dateadd(mi,1,t3.endtime) <= dateadd(mi,-1,t2.BeginTime)))
This is returning me:
RoomID   StartOfGap              EndOfGap             LengthOfGap
-----------------------------------------------------------------
14       01/25/2002 08:26:00    01/25/2002 07:31:00     8
14       01/25/2002 10:29:00    01/25/2002 08:34:00     4
On this date/Room the data is:
RoomID BeginTime     EndTime    
14     07:30          08:25
14     08:33          10:28
Desired Result for this data would be (assuming 60 minutes for the NeedTime)
RoomID   StartOfGap              EndOfGap             LengthOfGap
-----------------------------------------------------------------
14       01/25/2002 10:29:00    01/25/2002 17:00:00     330
Previous
Reply
Map
View

Click here to load this message in the networking platform