小编典典

仅在MYSQL DATEDIFF中显示小时

mysql

我已经忙了好几个小时了,但是我无法正常工作。

SQL

SELECT DATEDIFF(end_time, start_time) as `difference` FROM timeattendance WHERE timeattendance_id = '1484'

start_time =   2012-01-01   12:00:00
end_time =     2012-01-02   13:00:00

时差为25(小时)。但是我得到的输出是1(天)。

如何获得25小时的输出?


阅读 575

收藏
2020-05-17

共1个答案

小编典典

关于使用TIMESTAMPDIFF呢?

SELECT TIMESTAMPDIFF(HOUR, start_time, end_time) 
           as `difference` FROM timeattendance WHERE timeattendance_id = '1484'
2020-05-17