DATEDIFF()函数返回两个日期之间的时间 DATEDIFF(datepart,startdate,enddate)
– 获取两个日期之间的天数 SELECT DATEDIFF(day,‘2021-01-01’,‘2021-06-10’) AS days; SELECT DATEDIFF(day,‘2021-01-01 08:00:00’,‘2021-06-10 09:00:00’) AS days;
– 获取两个日期之间的月数 SELECT DATEDIFF(month,‘2021-01-
2024-11-07