YEARS Function (OpenOffice Calc)
Calculate year intervals with YEARS in Apache OpenOffice Calc. Compare calendar years, completed-month rules and leap-day anniversaries.
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: =YEARS(DATE(2024;2;29);DATE(2025;2;28);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 YEARS returns
YEARS returns a signed integer year interval. Mode 1 subtracts the endpoints’ calendar year numbers. Mode 0 first uses the complete-month calculation and then divides by twelve, truncating toward zero. It is not a fractional-year or universal age calculation. Release implementation.
Syntax and arguments
YEARS(StartDate;EndDate;Mode)
- StartDate, EndDate: required date serials or date cells.
- Mode: required integer selector: 0 for complete-year intervals derived from complete months, 1 for calendar-year difference.
- Both date parameters are integer serials in the add-in. Use valid date-only inputs deliberately.
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.YEARS, mapped to the English worksheet name YEARS by the release function map. The saved operation was verified after recalculation.
| Formula | Native 4.1.16 result | Independent reference |
|---|---|---|
=YEARS(DATE(2024;2;29);DATE(2025;2;28);0) |
0 |
0 |
=YEARS(DATE(2024;2;29);DATE(2025;3;1);0) |
1 |
1 |
=YEARS(DATE(2024;2;29);DATE(2025;2;28);1) |
1 |
1 |
=YEARS(DATE(2024;1;1);DATE(2024;12;31);0) |
0 |
0 |
=YEARS(DATE(2023;12;31);DATE(2024;1;1);0) |
0 |
0 |
=YEARS(DATE(2023;12;31);DATE(2024;1;1);1) |
1 |
1 |
=YEARS(DATE(2026;7;1);DATE(2024;1;1);0) |
-2 |
-2 |
=YEARS(DATE(2024;1;1);DATE(2026;7;1);0) |
2 |
2 |
Practical worksheet
From February 29, 2024 to February 28, 2025, Mode 0 gives 0, while Mode 1 gives 1. Moving the endpoint to March 1, 2025 makes the Mode 0 result 1. This follows the complete-month day-number rule, not a special policy assigning a February 28 anniversary to leap-day dates.
December 31, 2023 to January 1, 2024 gives 0 in Mode 0 and 1 in Mode 1. One day has elapsed, but a calendar-year boundary has been crossed. The mode decides which question is being answered.
Advanced interpretation and checks
Mode 0 is equivalent to truncating the signed complete-month count divided by 12. From January 1, 2024 to July 1, 2026 the complete-month count is 30, so the result is 2. Reversing that interval gives −2 rather than −3, because negative division truncates toward zero.
A fractional measure requires a different calculation. YEARFRAC uses a selected day-count basis and, in the verified OpenOffice release, sorts its endpoints rather than preserving their sign. Do not replace YEARS with YEARFRAC and assume only the number of decimal places changes.
Boundaries and troubleshooting
For age, service or contractual-anniversary calculations, specify the leap-day policy before using Mode 0. The tested February 29 example establishes the implementation’s rule but does not decide a legal or organizational anniversary convention.
The eight examples use valid ordinary dates and explicit modes. Other modes fall through to the interval calculation in source, but were not executed. Text dates, omitted arguments, invalid dates and extreme years are outside the native evidence. All results are integer year counts, not date serials.
Related functions
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.