DATEDIFF() 函数返回两个日期之间的时间。
语法:
DATEDIFF(datepart,startdate,enddate)
datepart 参数可以是下列的值:
,但一些英文也是支持的,如天:day,月:month,小时:hour,分:minute之类
1 SELECT DATEDIFF(day,'2008-12-29','2008-12-30') AS DiffDate
显示
1 SELECT DATEDIFF(day,'2008-12-30','2008-12-29') AS DiffDate
显示
1 SELECT DATEDIFF(MONTH,'2017-6-1','2017-6-30') AS DiffDate
显示