Show all Hide all


This function returns the number of completed years that separates two given dates, i.e. if the true difference is one and a half year, then this function returns a value of one year etc.

This is the type of calculation usually performed when reporting the age of a person.

A common misconception is that the function datediff(year, @Date1, @Date2) can be used to achieve the same result as described above.

This is false as what it really returns is the difference between the year values of the two dates, i.e. something functionally identical with year(@Date2) - year(@Date1).

Type: Scalar function
Area of use: General use

Return value: int

The difference in completed years.


@CreationDate mandatory datetime
The first date in the comparison.
@CompareDate mandatory datetime
The second date in the comparison. If set to DEFAULT then getdate() is used.