datediff函数入门

发布时间:2019-09-04编辑:脚本学堂
sql数据库datediff函数的用法,datediff函数的简单例子,一起来学习下。

sql datediff函数

DATEDIFF subtracts the first date from the second date.
The syntax for DATEDIFF is:

DATEDIFF ( datepart , startdate , enddate )

The first datepart code uses the same datepart codes as dateadd.
The second and third arguments are the date values that are part of the subtraction.

例子:
 

复制代码 代码示例:

4>
5> SELECT DATEDIFF(DY,"08/30/97","10/01/97")
6> GO

-----------
         32

(1 rows affected)
1>