开发者

Difference between two SQL timestamp values

How can I find the difference between two SQL timestamp values in 开发者_运维百科minutes and seconds?


Try the TIMEDIFF() function:

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

Example:

mysql> select timediff('2010-11-03 15:30:00','2010-11-03 14:00:00') as diff;
+----------+
| diff     |
+----------+
| 01:30:00 |
+----------+


Use TIMEDIFF:

SELECT TIMEDIFF(ts1, ts2) FROM ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜