TIMESTAMPDIFF
MySQL Function: TIMESTAMPDIFF
Categories:
TIMESTAMPDIFF(
<unit>
,<datetime_expr1>
,<datetime_expr2>
)
-- Result: 3
SELECT TIMESTAMPDIFF(MONTH,'2003-02-01','2003-05-01');
-- Result: -1
SELECT TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01');
-- Result: 128885
SELECT TIMESTAMPDIFF(MINUTE,'2003-02-01','2003-05-01 12:05:55');
Time Unit
- SECOND
- MINUTE
- HOUR
- DAY
- WEEK
- MONTH
- QUARTER
- YEAR