SQLTeam.com | Weblogs | Forums

Formula for a date and time

sql2008

#1

Hi I have date data for example
Start
2017-10-25 04:00:00

End
2017-10-25 05:00:00

I want to substract time between End and Start so the result will be
1 day 1 hour

please tell me the formula..

thx


#2

SELECT DATEDIFF(hh,'2017-10-25 04:00:00','2017-10-25 05:00:00')/24 AS 'Days'

    ,DATEDIFF(hh,'2017-10-25 04:00:00','2017-10-25 05:00:00') - 

    (DATEDIFF(hh,'2017-10-25 04:00:00','2017-10-25 05:00:00')/24)*24 AS 'Hours'

#3

thx...