Home >Database >Mysql Tutorial >mysql计算时间差函数_MySQL

mysql计算时间差函数_MySQL

WBOY
WBOYOriginal
2016-06-01 13:25:411192browse

bitsCN.com MySql计算两个日期的时间差函数TIMESTAMPDIFF用法:
语法:
TIMESTAMPDIFF(interval,datetime_expr1,datetime_expr2)  
说明:
返回日期或日期时间表达式datetime_expr1 和datetime_expr2the 之间的整数差。其结果的
单位由interval 参数给出。interval 的法定值同TIMESTAMPADD()函数说明中所列出的相同。 

SELECT TIMESTAMPDIFF(MONTH,'2009-10-01','2009-09-01');
interval可是:
SECOND 秒 SECONDS
MINUTE 分钟 MINUTES
HOUR 时间 HOURS
DAY 天 DAYS
MONTH 月 MONTHS
YEAR 年 YEARS
bitsCN.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn