Documentation/Calc Functions/YEARS

Function name:
YEARS

Category:
Date and Time

Summary:
Calculates the number of years between two dates.

Syntax:
YEARS(StartDate; EndDate; Type)

Returns:
Returns an integer value which is the difference between the two given dates in years, depending on the calculation mode selected through the Type argument.

Arguments:
StartDate is the date (in quotation marks) or a date-time serial number, or a reference to the cell containing one of those types, which is either the start date or the end date of the period for which the calculation is to be carried out.

EndDate is the date (in quotation marks) or a date-time serial number, or a reference to the cell containing one of those types, which is either the end date or the start date of the period for which the calculation is to be carried out.

Type is an integer value, either 0 or 1. If Type is 0, then YEARS returns the number of whole years between StartDate and EndDate (day/month to day/month). If Type is 1, YEARS identifies the year that each of StartDate and EndDate lie in, and then returns the difference between those years.


 * If either StartDate or EndDate is not a valid date expression, then YEARS returns a #VALUE! error.
 * If StartDate is earlier than EndDate, the result is a positive number; if StartDate is later than EndDate, the result is a negative number.
 * YEARS ignores any time components of StartDate and EndDate.
 * If Type is non-numeric, then YEARS reports a #VALUE! error.
 * If Type is a non-integer value, then YEARS truncates it to an integer.
 * If (after truncation) Type is not equal to either 0 or 1, then YEARS reports an invalid argument error (Err:502).

Details specific to YEARS function
YEARS is not part of the ODF 1.2 international standard and should not be regarded as portable.

Related LibreOffice functions:
DAYS

MONTHS

WEEKS

ODF standard:
None.

Equivalent Excel functions:
None.