0

I have a query

SELECT  CONVERT(VARCHAR(8), DATEADD(SS, DATEDIFF(SS, '2017/08/24 06:00', '2017/08/25 07:15'), 0), 114)

which gives output as 01:15:00, where the date is not considered. My expected output is 25:15:00 because the difference of the day is 1. I tried with replacing SS with HH but did not get the desired help.

Horia Coman
  • 8,681
  • 2
  • 23
  • 25
rinuthomaz
  • 1,393
  • 2
  • 23
  • 38

1 Answers1

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
sepupic
  • 8,409
  • 1
  • 9
  • 20