MONTHS Function (Calligra Sheets)
Understand Calligra Sheets MONTHS modes, month-end treatment and reversed dates, including the tested mode-one exclusion of a starting month boundary.
Verification status: 20 selected formulas were executed through the Calligra Sheets 25.04.2 calculation engine library in the C locale. Deterministic results were independently reconstructed; 26.08.2 was source-checked only. No GUI-cell or import claim. How formula examples are checked
Mode 1 limitation: In the tested 25.04.2 engine, January 1 to February 1 returns 0, and January 1 to itself returns −1. The source always advances the first date to the next month before counting. Do not treat this mode as a generic count of month boundaries.
Quick answer: =MONTHS(DATE(2025;1;15);DATE(2025;4;15);0) returns 3 in the tested engine.
Availability and version history
- Introduced: First release not established; the name is present in Calligra 2.4.0 source.
- Supported in: Calligra Sheets 26.08.2, with the limitations described here; no retirement established.
- Scope: Desktop Sheets with the Date & Time module. Formulas use English names and semicolon separators.
- Checked: October 14, 2026: selected 25.04.2 engine-library formulas and independent calendar/time reconstructions; 26.08.2 source only. The test locale was C, with Monday as its week start. No GUI-cell or import execution is claimed.
What MONTHS returns
MONTHS returns an integer using one of two calendar algorithms. Mode 0 starts with the difference in year/month coordinates and can subtract one when the ending day is earlier. Mode 1 counts between an advanced starting month and the ending month. The examples make the endpoint rules explicit. Official function reference.
Syntax and arguments
=MONTHS(start_date;end_date;type)
start_date, end_date and type are all required. Type 0 selects the day-sensitive count. Any nonzero converted integer selects the other branch; the documented choice is 1. Fractional type values use the converter’s floor operation, so .9 selects 0 and 1.9 selects 1. Registration and implementation.
Reproducible engine examples
Numeric results are rounded here to twelve decimal places. The reconstruction column applies independent calendar arithmetic or the explicitly inspected time/conversion rule. Date serials use the tested default reference date; they do not show native GUI date formatting.
| Formula | Engine result | Independently reconstructed calendar or time rule |
|---|---|---|
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);0) |
3 |
3 |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);1) |
2 |
2 |
=MONTHS(DATE(2025;1;31);DATE(2025;2;28);0) |
1 |
1 |
=MONTHS(DATE(2025;1;31);DATE(2025;2;27);0) |
0 |
0 |
=MONTHS(DATE(2025;1;1);DATE(2025;2;1);1) |
0 |
0 |
=MONTHS(DATE(2025;1;1);DATE(2025;1;1);1) |
-1 |
-1 |
=MONTHS(DATE(2025;4;15);DATE(2025;1;15);0) |
-3 |
-3 |
=MONTHS(DATE(2024;12;15);DATE(2025;3;20);1) |
2 |
2 |
Practical worksheet
Put =DATE(2025;1;31) in A2 and =DATE(2025;2;28) in B2. =MONTHS(A2;B2;0) returns 1, because the ending date is the last day of its month. Moving B2 to February 27 returns 0. This month-end exception is useful to recognize when comparing periods anchored on the 31st.
For January 15 to April 15, mode 0 gives 3 and mode 1 gives 2. Choose the mode from the actual endpoint definition you need, rather than from the word Complete in a column heading.
Advanced interpretation and checks
If the desired quantity is the difference between year/month coordinates, a separate expression is clearer: with A2 containing January 1, 2025 and B2 containing February 1, 2025, use =(YEAR(B2)-YEAR(A2))*12+MONTH(B2)-MONTH(A2). The equivalent explicit-date formula was executed and returned 1. It counts month boundaries without making a complete-elapsed-month claim.
For contrast, the following native MONTHS mode-1 expression returned zero. Its result follows the unconditional advance of the starting month, even when that date is already the first.
=MONTHS(DATE(2025;1;1);DATE(2025;2;1);1)
The executed result was 0.
Boundaries and troubleshooting
Reversed dates are not reordered before this calculation. Day-sensitive decrements can make reverse results asymmetric, so do not blindly negate a forward result. Invalid date text and a division-by-zero date both produced 1,503 in the shown boundary cases rather than errors. An erroneous type converted to zero. The two-argument call is invalid; omitting the mode does not select a default.
| Formula | Engine result |
|---|---|
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);2) |
2 |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);-1) |
2 |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);.9) |
3 |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);1.9) |
2 |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);"abc") |
3 |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);1/0) |
3 |
=MONTHS("abc";DATE(2025;4;15);0) |
1503 |
=MONTHS(1/0;DATE(2025;4;15);0) |
1503 |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15)) |
#VALUE! |
=MONTHS(DATE(2025;1;15);DATE(2025;4;15);0;0) |
#VALUE! |
=(YEAR(DATE(2025;2;1))-YEAR(DATE(2025;1;1)))*12+MONTH(DATE(2025;2;1))-MONTH(DATE(2025;1;1)) |
1 |
Official evidence and precision scope
- Function-specific implementation
- Versioned help
- Date Conversion
- Integer Conversion
- Integer Floor
- Reference Date
The selected callbacks, date/time module and inspected conversion/time helpers are byte-identical between the retained 25.04.2 and 26.08.2 sources. This establishes source continuity for the described paths, not execution of the later release.