Functions and operators : DIFF_YEAR( )

DIFF_YEAR( )

Calculates the number of years between two date values.

Syntax

DIFF_YEAR(date1, date2)

Arguments

date1

The first date or date expression to use in the calculation.

date2

The second date or date expression to use in the calculation.

Returns

The number of years between date1 and date2. The function calculates the difference by subtracting the year number of date1 from the year number of date2. For example, if date1 is 1/1/08 and date2 is 12/31/08, DIFF_YEAR( ) returns 0. If date1 is 11/25/08 and date2 is 1/5/09, DIFF_YEAR( ) returns 1.

Example

The following example calculates the number of years between each value in the HireDate data field and each value in the TerminationDate data field.

DIFF_YEAR([HireDate],[TerminationDate])

The following example calculates the number of years from each value in the HireDate data field to the current date. TODAY( ) is a function that returns the current date.

DIFF_YEAR([HireDate], TODAY())