Thursday, March 5, 2015

sql server Compare Time Field between interval

declare @ts1 as time;
SELECT @ts1 = CAST('08:00:00 AM' AS TIME);

declare @ts2 as time;
SELECT @ts2 =CAST('12:00:00 PM' AS TIME);

select * from tasks.dbo.Tasks_PerHour_view
where jobtime between  CONVERT(time(0), @ts1) and CONVERT(time(0), @ts2)

No comments:

Post a Comment