DATEDIFF
Returns the difference between two dates in the units (days, months, or years) specified.
Syntax: DATEDIFF(
start_date
,
end_date
,
interval
)
start_date
andend_date
are the two dates to calculate the difference between.interval
is the units in which theDATEDIFF
function reports the difference between the two dates. It can take one of the following values:“Y” for year
“M” for month
“D” for days
Note: All three arguments (parameters) are required.
Example: DATEDIFF ( DATE ( 2022 , 1 , 1 ) , DATE ( 2022 , 12 , 31 ) , "D" )
Output: 364
Example: DATEDIFF ( DATE ( 2022 , 1 , 1 ) , DATE ( 2022 , 12 , 31 ) , "M" )
Output: 11
Example: DATEDIFF ( DATE ( 2022 , 1 , 1 ) , DATE ( 2022 , 12 , 31 ) , "Y" )
Output: 0
Last updated
Was this helpful?