How to get the difference between two dates rounded to hours

前端 未结 8 1302

I\'ll illustrate what I would like to get in the following example:

\'2010-09-01 03:00:00\' - \'2010-09-01 00:10:00\'

Using TIMEDIFF(

相关标签:
8条回答
  • 2020-12-04 22:01

    Its a very old thread, but you can also try TIMESTAMPDIFF and give MINUTE, HOUR, SECONDS as the qualifier.

    http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_timestampdiff

    0 讨论(0)
  • 2020-12-04 22:03

    If you are using timestamp, this could be the solution in MySQL using SQL.

    SELECT TIMESTAMPDIFF(HOUR, '2010-11-29 13:13:55', '2010-11-29 13:16:55') as newtable;
    
    | newtable |
    
    7
    
    1 row in set (0.01 sec)
    
    0 讨论(0)
提交回复
热议问题