mysql timediff to hours

前端 未结 10 1764
我寻月下人不归
我寻月下人不归 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:30

    select hour(timediff('2017-01-01 00:00:00', '2017-01-01 00:01:00'));
     return 1
    
    select hour(timediff('2017-01-01 00:01:00', '2017-01-01 00:00:00'));
     return 1 
    
    select time_to_sec(timediff('2017-01-01 00:00:00', '2017-01-01 00:00:05'));
    return -5
    
    select time_to_sec(timediff('2017-01-01 00:00:00', '2017-01-01 00:00:05'))/60 as 'minutes' ;
    return -0.0833  
    

    if you have the seconds you can convert it as you want or what and hours(..) will not use it when i compare because it's always postive value

提交回复
热议问题