Contact

YEARS Function (Calligra Sheets)

Date & Time Intermediate Calligra Sheets

Use Calligra Sheets YEARS with anniversary and calendar-year modes. Check leap-day endpoints, reversed spans and required mode arguments before use.

Verification status: 17 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

Endpoint warning: The tested reverse interval is not always the negative of the forward interval. Leap-day anniversaries also need an explicit convention: February 29, 2024 to February 28, 2025 returned 0 in mode 0.

Quick answer: =YEARS(DATE(2023;6;15);DATE(2025;6;15);0) returns 2 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 YEARS returns

YEARS counts by calendar fields rather than dividing days by 365. Mode 0 subtracts one from the year-coordinate difference when the ending month/day precedes the starting month/day. Mode 1 counts whole intervening calendar years after moving a non-January-1 start to the next January 1. Official function reference.

Syntax and arguments

=YEARS(start_date;end_date;type)

start_date, end_date and type are required. The documented modes are 0 and 1; any nonzero converted integer selects the calendar-year branch. The converter floors fractional modes. Neither branch is a general fractional-year calculation. 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
=YEARS(DATE(2023;6;15);DATE(2025;6;15);0) 2 2
=YEARS(DATE(2023;6;15);DATE(2025;6;14);0) 1 1
=YEARS(DATE(2023;6;15);DATE(2025;6;15);1) 1 1
=YEARS(DATE(2023;1;1);DATE(2025;6;15);1) 2 2
=YEARS(DATE(2024;2;29);DATE(2025;2;28);0) 0 0
=YEARS(DATE(2025;6;15);DATE(2023;6;14);0) -3 -3
=YEARS(DATE(2025;1;1);DATE(2025;12;31);1) 0 0
=YEARS(DATE(2025;6;15);DATE(2023;6;15);1) -3 -3

Practical worksheet

Put =DATE(2023;6;15) in A2 and =DATE(2025;6;15) in B2. =YEARS(A2;B2;0) returns 2. Moving B2 one day earlier returns 1. Mode 1 returns 1 for the original pair because only the full calendar year 2024 lies after the adjusted start and before the ending year.

Starting instead on January 1, 2023 leaves that year included in the calendar-year calculation, so the mode-1 result to June 15, 2025 is 2. Describe which rule a report uses; these formulas alone do not establish legal age or eligibility rules.

Advanced interpretation and checks

The day-sensitive correction is applied even when dates are reversed. June 15, 2023 to June 14, 2025 gives 1; reversing those exact dates gives −2. Their sum is −1, as checked by the expression below.

For leap-day starts, the code compares month and day literally. February 28 is earlier than February 29, so the 2024-to-2025 anniversary example has not reached a full year under this algorithm. A workflow using a February-28 anniversary convention must define that separately.

=YEARS(DATE(2023;6;15);DATE(2025;6;14);0)+YEARS(DATE(2025;6;14);DATE(2023;6;15);0)

The executed result was -1.

Boundaries and troubleshooting

Mode 1 returns zero when the dates have the same calendar year; otherwise a non-January-1 start advances one year, including for reversed dates. Malformed date text and input errors were converted to the reference date in the shown cases, yielding 125 rather than an error. A failed mode conversion selects zero. Wrong argument counts returned actual #VALUE! errors.

Formula Engine result
=YEARS(DATE(2025;1;15);DATE(2025;4;15);2) 0
=YEARS(DATE(2025;1;15);DATE(2025;4;15);.9) 0
=YEARS(DATE(2025;1;15);DATE(2025;4;15);"abc") 0
=YEARS(DATE(2025;1;15);DATE(2025;4;15);1/0) 0
=YEARS("abc";DATE(2025;4;15);0) 125
=YEARS(1/0;DATE(2025;4;15);0) 125
=YEARS(DATE(2025;1;15);DATE(2025;4;15)) #VALUE!
=YEARS(DATE(2025;1;15);DATE(2025;4;15);0;0) #VALUE!

Official evidence and precision scope

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.