Documentation/How Tos/Calc: MONTHS function

From Apache OpenOffice Wiki
< Documentation‎ | How Tos
Revision as of 05:20, 19 February 2008 by Drking (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


MONTHS

Returns the number of weeks between two dates.

This function is only available if the Analysis AddIn is installed.

Syntax:

MONTHS(startdate; enddate; mode)

if mode is 0, MONTHS returns the number of whole months between startdate and enddate, day of the month to day of the month (see examples).
if mode is 1, MONTHS identifies the month that startdate and enddate each lie in, and returns the difference between those months. In other words it returns MONTH(enddate) - MONTH(startdate) + 12 * (YEAR(enddate) - YEAR(startdate)).
If startdate is after enddate the result will be negative.

Example:

MONTHS("2010-04-03"; "2011-06-17"; 0)

returns 14, the number of months between 3 April 2010 and 17 June 2011.

MONTHS("2010-03-31"; "2010-04-30"; 0)

returns 0. 31 March to 30 April is not considered a whole month, even though they are both the last day of their months.

MONTHS("2010-03-31"; "2010-06-30"; 0)

returns 2. Even though both dates are the last day of their months, the last month is not counted, because the day is less than 31.

MONTHS("2010-04-03"; "2011-06-17"; 1)

returns 14, the number of months between April 2010 and June 2011.

MONTHS("2010-03-31"; "2010-04-01"; 1)

returns 1. Even though the dates are just one day apart, they lie in different months.

See also:

DAYS, WEEKS, YEARS

Date & Time functions

Date & Time overview

Personal tools