How to get the difference between two dates rounded to hours

前端 未结 8 1317

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 21:39

    I think a more complete answer is

    select time_format(timediff(onedateinstring,anotherdateinstring),'%H:%i:%s')
    

    This allows you to see the hours, minutes, seconds, etc. that you wish to see in the format you want...

    More information on time_format: http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_time-format

提交回复
热议问题