我通过以下查询获取当前系统时间
select cast(DATEPART(hh,getdate()) as varchar)+ ':'+ cast(DATEPART(n,getdate()) as varchar)
现在如何将此当前系统时间与时间字段进行比较以查看哪个更大?
-----------------------
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
-----------------------
时间字段具有以下格式的时间
0400
0415
0430
我看到了这个支持功能。现在如何将@time1 部分更改为“从表中选择时间”
谢谢