YEARFRAC function

YEARFRAC(Date1, Date2, Basis?) YEARFRAC(Date1; Date2; Basis?)

Date1

Number or { Number }

The first date, as a sequential serial number.

Date2

Number or { Number }

The second date, as a sequential serial number.

Basis

Number or { Number } (optional)

The day counting system. If omitted, it is assumed to be 0. Refer to the table for more information.

Returns

Number or { Number }

The number of years between the two given dates, as a decimal number.

Returns the number of years between the two given dates, as a decimal number.

The optional basis parameter can be used to change how days are counted. The default value assumes that all 12 months have 30 days each. Use this table to determine what number to use:

Valid values for the basis parameter
Value Day counting system
0 (default) US (NASD) system. Months are assumed to have 30 days each, meaning that all years have 360 days. If the first date parameter falls on the last day of the month, it is assumed to fall on the 30th instead. If the second date parameter falls on the last day of the month, and the first date parameter falls on the 29th of the month or earlier, the second date parameter is assumed to fall on the first of the following month. Otherwise, the second date parameter is assumed to fall on the 30th of the same month.
1 Months have the correct number of days. Leap years have 366 days and regular years have 365 days.
2 Months have the correct number of days, which are compressed into a 360-day year.
3 Months have the correct number of days, which are compressed into a 365-day year.
4 A European system. Months are assumed to have 30 days each, meaning that all years have 360 days. If a date falls on the 31st of a month, it is assumed to fall on the 30th instead.

Example

YEARFRAC(DATE(1981, 5, 1), DATE(2013, 1, 1))YEARFRAC(DATE(1981; 5; 1); DATE(2013; 1; 1))

Returns roughly 31.67 years.