I have been unable to figure out how to select records between 1900 hrs to 0700 hrs that span over midnight The result I get is Zero records returned. Do I need to break this down into two select statements? 19 to 23 and 0 to 7 and add the results together or can this be done in one statement? Below is a small portion of my sql statement from the stored procedure. I have attached the full sp if needed.
The two select statements I have problems with are @Thirdshift... and@12HourSecond....
Using SQL Server 2014
DECLARE @ThirdShiftStart As Datetime
DECLARE @ThirdShiftEnd As Datetime
SET @ThirdShiftStart = 16
SET @ThirdShiftEnd = 0
(SELECT Count(*) FROM E911Data WHERE Agency = @Agency and Year(EntryDateTime) = @Year and
me) >= @ThirdShiftStart and datepart(hour,EntryDateTim
e) < @ThirdShiftEnd) as CurrentYearThirdShift