sql datediff函数
例1,
3> select DATEDIFF(day, '2001-12-01', '2002-09-30')
4> GO
-----------
303
(1 rows affected)
例2,
3> select DATEDIFF(month, '2001-12-01', '2002-09-30')
4> GO
-----------
9
(1 rows affected)
例3,
3> select DATEDIFF(year, '2001-12-01', '2002-09-30')
4> GO
-----------
1
(1 rows affected)
例4,
3> select DATEDIFF(hour, '06:46:45', '11:35:00')
4> GO
-----------
5
(1 rows affected)
例5,
3> select DATEDIFF(minute, '06:46:45', '11:35:00')
4> GO
-----------
289
(1 rows affected)
例6,
3> select DATEDIFF(second, '06:46:45', '11:35:00')
4> GO
-----------
17295
(1 rows affected)
例7,
2>
3> select DATEDIFF(quarter, '2001-12-01', '2002-09-30')
4> GO
-----------
3
(1 rows affected)