Number of Months Between Two Dates (YEARS)

Syntax: YEARS(t1; t2; Year_Type)

The YEARS function calculates the number of years between two dates, either in yearly intervals (0) or calendar years (1). For example:

=YEARS(DATE(2009; 12; 31); DATE(2010; 1; 1); 0)

returns 0, because the difference between these two dates is less than the length of a full year, and

=YEARS(DATE(2009; 12; 31); DATE(2010; 1; 1); 1)

returns 1, because in calendar terms there is a difference of one year between those two dates.

images

Figure 12-17. Sample results of the YEARS function

You can give YEARS the date in a more natural format:

=YEARS("12/31/2010"; "1/1/2010"; ...

Get Beginning OpenOffice Calc: From Setting Up Simple Spreadsheets to Business Forecasting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.