I am getting the current system time with the following query
select cast(DATEPART(hh,getdate()) as varchar)+ ':'+ cast(DATEPART(n,getdate()) as varchar)
Now how do I compare this current system time with a time field to see which is larger?
-----------------------
declare @time1 datetime,
@time2 datetime
select @time1 = '20060701 02:27:35.35',
@time2 = getdate()
select tm1, tm2,
case
when tm1 = tm2 then 'tm1 = tm2'
when tm1 > tm2 then 'tm1 > tm2'
else 'tm1 < tm2'
end as [TimeDiff]
from
(
select dateadd(day, -datediff(day, 0, @time1), @time1) as tm1,
dateadd(day, -datediff(day, 0, @time2), @time2) as tm2
) t
-----------------------
The time field has time in the following format
0400
0415
0430
I see this supporting Function. Now how do I alter the @time1 part to “select time from table”
Thanks
try this: