TIMESTAMPDIFF用法:
TIMESTAMPDIFF(interval,datetime_expr1,datetime_expr2)
返回日期或日期时间表达式datetime_expr1 和datetime_expr2the 之间的整数差。
mysql> SELECT TIMESTAMPDIFF(MONTH,'2009-12-01','2009-09-01');
mysql> SELECT TIMESTAMPDIFF(YEAR,'2009-05-01','2008-01-01');
select TIMESTAMPDIFF(SECOND,DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s'),'2013-03-07 15:43:00')
from dual
SELECT DATE_FORMAT(MIN(entertime),'%Y-%m-%d') as startDt, DATE_FORMAT(MAX(entertime), '%Y-%m-%d') as endDt
FROM table
- FRAC_SECOND。表示间隔是毫秒
- SECOND。秒
- MINUTE。分钟
- HOUR。小时
- DAY。天
- WEEK。星期
- MONTH。月
- QUARTER。季度
- YEAR。年