Calculates the days, weeks, months between two dates.
DATEDIFF(DATETIME_1, DATETIME_2, INTERVAL)
The following is a list of the recognized values for the INTERVAL value:
DATEDIFF(@Date [email protected], @Date [email protected], “months”)
Notes on use:The DATETIME you provide must be a datetime object, a column that contains a datetime object, or a function that returns a datetime object. The INCREMENT provided must be an integer. Millis accepts a maximum of +/- 2147483647.
It is recommended you use the latest datetime value for the DATETIME_2. If you enter the earliest date as the DATETIME_2 value, the DATEDIFF function will return a negative number.
DATEDIFF always rounds the result down to the nearest whole number. For example, if the difference between two dates is 3 years and 11 months, the DATEDIFF function returns the difference as 3 years.