计算两个时间差 如:2009-11-21 00:00:00
和2009-11-24 15:12:24
计算两个时间差 如:2009-11-21 00:00:00
和2009-11-24 15:12:24
declare @starttime as datetime
declare @endtime as datetime
set @starttime = '2009-11-21 00:00:00'
set @endtime = '2009-11-24 15:12:24'
select right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) / 3600 as int) as varchar),2) + ':' +
right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) % 3600 / 60 as int) as varchar),2) + ':' +
right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) % 60 as int) as varchar),2) as 时间差
时间差
--------------
87:12:24
(1 行受影响)