TIMESTAMPDIFF用法

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

 

  1. FRAC_SECOND。表示间隔是毫秒
  2. SECOND。秒
  3. MINUTE。分钟
  4. HOUR。小时
  5. DAY。天
  6. WEEK。星期
  7. MONTH。月
  8. QUARTER。季度
  9. YEAR。年
posted @ 2016-06-30 14:57  馳騁衿琾  阅读(19445)  评论(0编辑  收藏  举报