Contact

MONTHS Function (OpenOffice Calc)

Date & Time Intermediate OpenOffice Calc

Use MONTHS in Apache OpenOffice Calc for complete or calendar-month intervals. See month-end behavior, reversed dates and reproducible examples.

Verification status: Eight ordinary reference formulas were recalculated in Apache OpenOffice 4.1.16 on Linux x86-64, Build 9816, through generated native ODF and GUI hard recalculation. Saved identities, inputs and results were checked. The registered ORG.OPENOFFICE storage name was used; English-name availability is source-checked. How formula examples are checked

Quick answer: =MONTHS(DATE(2024;1;31);DATE(2024;2;29);0) returned 0 in the tested Apache OpenOffice 4.1.16 build.

Availability and version history

  • Introduced: First release not established; documented by OpenOffice.org 3.3.
  • Supported in: Apache OpenOffice 4.1.16; this is a verified release, not a final supported version.
  • Scope: Desktop Calc, English function names and semicolon-separated formulas.
  • Checked: October 14, 2026. Eight ordinary reference formulas were recalculated from generated ODF in 4.1.16 on Linux x86-64, Build 9816. Source and independent arithmetic were checked.

What MONTHS returns

MONTHS returns a signed integer month difference. Mode 1 compares calendar year/month numbers and ignores day-of-month. Mode 0 adjusts that difference when the end has not reached the starting day number. It is not elapsed days divided by a fixed month length and does not use EDATE’s end-of-month clamping rule. Release implementation.

Syntax and arguments

MONTHS(StartDate;EndDate;Mode)
  • StartDate, EndDate: required date values or date cells.
  • Mode: required integer selector: 0 for complete-month intervals, 1 for calendar-month differences. The implementation uses the interval branch for other modes; choose 0 or 1 explicitly.
  • Use DATE expressions or typed dates rather than locale-dependent text.

Eight reproducible examples

The native column contains saved 4.1.16 results; independent references use high-precision arithmetic and the stated source rules. Values are shown to twelve decimal places where needed. Enter DATE expressions directly rather than locale-dependent date text.

The generated ODF uses ORG.OPENOFFICE.MONTHS, mapped to the English worksheet name MONTHS by the release function map. The saved operation was verified after recalculation.

Formula Native 4.1.16 result Independent reference
=MONTHS(DATE(2024;1;31);DATE(2024;2;29);0) 0 0
=MONTHS(DATE(2024;1;31);DATE(2024;2;29);1) 1 1
=MONTHS(DATE(2024;1;15);DATE(2024;2;15);0) 1 1
=MONTHS(DATE(2024;3;31);DATE(2024;1;31);0) -2 -2
=MONTHS(DATE(2024;3;1);DATE(2024;1;31);0) -1 -1
=MONTHS(DATE(2023;12;15);DATE(2025;1;15);0) 13 13
=MONTHS(DATE(2024;6;1);DATE(2024;6;1);1) 0 0
=MONTHS(DATE(2024;1;31);DATE(2024;3;30);0) 1 1

Practical worksheet

From January 31 to February 29, 2024, Mode 0 gives 0, because the end day 29 has not reached the starting day 31. Mode 1 gives 1, because the dates lie in adjacent calendar months. From January 15 to February 15, Mode 0 gives 1.

This is important for a report that counts monthly periods. If the intended anniversary rule treats a short month’s final day as the monthly anniversary, MONTHS Mode 0 is not automatically that rule. State whether the report counts boundaries, reached day numbers or a separate anchored schedule.

Advanced interpretation and checks

The initial calendar difference is 12*(end_year-start_year)+end_month-start_month. In forward Mode 0 intervals, subtract one if the end day is smaller than the start day. In reversed intervals, add one if the end day is larger than the start day. Equal dates return zero.

March 1 back to January 31, 2024 gives −1 in Mode 0: the calendar difference is −2, adjusted toward zero because the end day 31 exceeds the starting day 1. January 31 to March 30 gives 1, despite crossing two calendar-month boundaries. These examples expose the day-number rule directly.

Boundaries and troubleshooting

Do not estimate complete months using 30 or 30.4375 days. Those are different models. The source’s interval rule is signed and uses actual endpoint day numbers; EDATE may clamp a date and then lose that original day number in chained calculations.

The tests cover eight valid dates and explicit modes, including reversed and equal endpoints. Missing arguments, text parsing, fractional serial conversion and extreme dates were not executed. A date serial copied between different workbook date systems needs interpretation before these comparisons are meaningful.

Official evidence and checking scope

The generated ODF produced the informational load warning “Not all attributes could be read.” The sheet was hard-recalculated and saved separately. All eight ordinary function identities, inputs and results were reconciled; a stale SUM cache changed from 999999 to 3 and an uncached SUM returned 7. This establishes the stated examples, not every workbook style or invalid input. Other explanatory identities are independent calculations. The authoring-tool XLSX was not executed in OpenOffice, and its preview values are not the native results reported here.