Difference between revisions of "Documentation/How Tos/Calc: YEARS function"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Example:)
(Issues)
Line 38: Line 38:
  
 
'''[[Documentation/How_Tos/Calc: Date & Time functions#Date and Time overview|Date & Time overview]]'''
 
'''[[Documentation/How_Tos/Calc: Date & Time functions#Date and Time overview|Date & Time overview]]'''
 +
 +
=== Issues: ===
 +
* This function is not available in Excel.

Revision as of 05:25, 22 July 2008


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.

See also:

DAYS, WEEKS, MONTHS

Date & Time functions

Date & Time overview

Issues:

  • This function is not available in Excel.
Personal tools