我有一个查询
SELECT CONVERT(VARCHAR(8), DATEADD(SS, DATEDIFF(SS, '2017/08/24 06:00', '2017/08/25 07:15'), 0), 114)
,输出为 01:15:00 ,其中不考虑日期。我的预期输出是 25:15:00 ,因为当天的差异为1.我尝试用HH取代SS,但没有得到所需的帮助。
答案 0 :(得分:3)
with cte as
(
select DATEDIFF(SS, '2017/08/24 06:00', '2017/08/25 07:15') as ss
)
select cast (ss/3600 as varchar(10)) +':' + right( '00' +cast(ss % 3600 / 60 as varchar(2)), 2) + ':' + right( '00' + cast( (ss % 3600 )% 60 as varchar(2)), 2)
from cte