MySql calculate time difference function

MySql calculates the time difference between two dates using the TIMESTAMPDIFF function, which can be done with a single SQL statement.

SELECT TIMESTAMPDIFF(MONTH,'2009-10-01','2009-09-01');

The first parameter can be:

SECOND seconds SECONDS 
MINUTE minutes MINUTES 
HOUR time HOURS 
DAY days DAYS 
MONTH months MONTHS 
YEAR years YEARS

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326844123&siteId=291194637