fatih
fatih

Reputation: 1181

Difference between two SQL timestamp values

How can I find the difference between two SQL timestamp values in minutes and seconds?

Upvotes: 1

Views: 1408

Answers (2)

Mark Byers
Mark Byers

Reputation: 839114

Use TIMEDIFF:

SELECT TIMEDIFF(ts1, ts2) FROM ...

Upvotes: 1

Ike Walker
Ike Walker

Reputation: 65587

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 |
+----------+

Upvotes: 3

Related Questions