Documentation/How Tos/Calc: YEARS function
From Apache OpenOffice Wiki
YEARS
Returns the number of years between two dates.
This function is only available if the Analysis AddIn is installed.
Syntax:
YEARS(startdate; enddate; mode)
- If mode is 0, YEARS returns the number of whole years between startdate and enddate, day/month to day/month.
- If mode is 1, YEARS identifies the year that startdate and enddate each lie in, and returns the difference between those years. In other words it returns YEAR(enddate) - YEAR(startdate)
- If startdate is after enddate the result will be negative.
Example:
YEARS("2009-04-03"; "2011-11-17"; 0)
- returns 2.
YEARS("2011-02-28"; "2012-02-28"; 0)
- returns 1. 2012 is a leap year, but 28th February to 28th February is classed as a whole year.
YEARS("2012-02-29"; "2013-02-28"; 0)
- returns 0. 2012 is a leap year, but 29th February to 28th February is not classed as a whole year, even though both dates are the last day of February.
YEARS("2009-04-03"; "2011-11-17"; 1)
- returns 2.
YEARS("2009-12-31"; "2010-01-01"; 1)
- returns 1. Even though there is only one day between the dates, they lie in different years.
Issues:
- This function is not available in Excel.