mysql中时间间隔函数timestampdiff
函数TimeStampDiff()是MySQL本身提供的可以计算两个时间间隔的函数,语法为:TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2),其中unit单位有如下几种,分别是:
FRAC_SECOND (microseconds), SECOND
, MINUTE
, HOUR
, DAY
, WEEK
, MONTH
, QUARTER
, or YEA
举例,时间间隔秒数:
SELECT TIMESTAMPDIFF(SECOND,’2014-01-01 10:10:10′,’2014-01-01 10:10:11′);
欢迎转载,请注明出处:亲亲宝宝