mysql timediff to hours

前端 未结 10 1780
我寻月下人不归
我寻月下人不归 2020-12-13 08:47

I\'m Trying to get the timediff from my table and convert it to hours (it\'s for an hourly billed service)

SELECT TIME_TO_SEC(TIMEDIFF(endDate,startDa

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 09:14

    NOTE the most voted up answer in this chain is INCORRECT! Using HOUR will only return hours as an integer. Below would correct the most popular answer to return hours as an integer and minutes as a decimal (ie 6.5 hours).

    TIME_TO_SEC(TIMEDIFF(endDate, startDate))/3600 as hours
    

提交回复
热议问题