[SQL study notes] DATEDIFF function: date calculation of the difference between days

How to call

Note: This note only applies to SQL Server database
DATEDIFF (parameter one, parameter two, parameter three)

Incoming parameters

Parameter 1: Specify the difference type. When DAY is passed, the returned result represents the number of days difference.
Parameter 2: The larger of the two date values.
Parameter 3: The smaller of the two date values.

return value

Returns the difference of the specified difference type

Call example

-- 返回当前日期与表Table1所存储的CreateTime之间相差的天数
DATEDIFF(DAY,GETDATE(),Table1.CreateTime)
Published 23 original articles · Like1 · Visits 20,000+

Guess you like

Origin blog.csdn.net/shenjie_xsj/article/details/105193043