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 ...
精彩评论