Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help With Query
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01245198
Message ID:
01245203
Views:
16
I'm not sure what you mean by "try the changes inside". I did get the query to run, but it is returning the wrong shift (falling into the else clause and returning zero) for the first record.
Example data:
Room    AnesStart                AnesEnd         ShiftNumber
ROOM1   05/15/2007 03:05:00 05/15/2007 04:31:00     2
ROOM1   05/15/2007 19:01:00 05/15/2007 22:35:00     2
ROOM2   05/16/2007 06:30:00 05/16/2007 07:45:00     2
Query
select 
  (Select substring(roomname,1,10) from coRooms where coRooms.RoomID=meetings.RoomID) as RoomDesc,
  datediff(mi,dbo.meetings.anesstart,dbo.meetings.anesend) as AnesMins,
  dbo.meetings.AnesStart,
  dbo.meetings.AnesEnd,
    case  when substring(convert(varchar(5),dbo.meetings.anesstart,114),1,5) between  @Shift1Start  and  @Shift1End then 1
          when substring(convert(varchar(5),dbo.meetings.anesstart,114),1,5) between  @Shift2Start  and  @Shift2End then 2
      else 0
      end as ShiftNumber,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform