YEAR Function (LibreOffice Calc)
The YEAR function extracts the year component from a date or datetime value. It is essential for date analysis, reporting, grouping, and constructing or validating date logic.
Compatibility
▾| Excel | ✔ |
| Gnumeric | ✔ |
| Google_sheets | ✔ |
| Libreoffice | ✔ |
| Numbers | ✔ |
| Onlyoffice | ✔ |
| Openoffice | ✔ |
| Wps | ✔ |
| Zoho | ✔ |
What the YEAR Function Does ▾
- Extracts the year from a date or datetime
- Accepts serial numbers, real dates, or converted text
- Returns a four‑digit integer
- Ignores month, day, and time components
It is designed to be simple, reliable, and ideal for date‑component extraction.
Syntax ▾
YEAR(date_value)
Arguments
- date_value:
A date, datetime, or serial number representing a date.
Basic Examples ▾
Extract year from a date
=YEAR("2024-03-15")
Returns 2024.
Extract year from a datetime
=YEAR("2024-03-15 08:45")
Returns 2024.
Extract year from a cell
=YEAR(A1)
Extract year from TODAY()
=YEAR(TODAY())
Advanced Examples ▾
Extract year from text using DATEVALUE
=YEAR(DATEVALUE(A1))
Extract year from imported CSV timestamps
=YEAR(DATEVALUE(LEFT(A1;10)))
Extract year from Excel serial dates imported as text
=YEAR(DATE(1899;12;30)+VALUE(A1))
Determine if two dates are in the same year
=YEAR(A1)=YEAR(B1)
Build a year label
="Year " & YEAR(A1)
Extract fiscal year (April–March example)
=YEAR(A1 - 90)
Extract ISO year (not always same as calendar year)
=YEAR(A1 - WEEKDAY(A1;2) + 4)
Extract year from a timestamp with timezone text
=YEAR(DATEVALUE(LEFT(A1;10)))
Extract year from YYYYMMDD text
=YEAR(DATEVALUE(LEFT(A1;4) & "-" & MID(A1;5;2) & "-" & RIGHT(A1;2)))
Edge Cases and Behavior Details ▾
YEAR returns an integer
Accepts:
- Real dates
- Serial numbers
- DATEVALUE outputs
- ISO date strings
Invalid text → Err:502
YEAR ignores:
- Time components
- Timezones
- Seconds/milliseconds
- Everything after the date portion
YEAR of a number < 1 → Err:502
(Serial numbers must represent valid dates)
YEAR of an error → error propagates
Common Errors and Fixes ▾
Err:502 — Invalid argument
Cause:
- Text not recognized as a date
- Negative serial numbers
- Non-numeric values
Fix:
- Wrap with DATEVALUE
- Clean text with TRIM or SUBSTITUTE
Wrong year due to locale parsing
Fix:
- Convert to ISO format before DATEVALUE
YEAR returns unexpected value from serial numbers
Cause:
- Serial numbers represent days since epoch
Fix:
- Ensure imported values are converted properly
Best Practices ▾
- Use YEAR for grouping and reporting
- Normalize text dates with DATEVALUE
- Use YEAR with MONTH and DAY to reconstruct dates
- Use YEAR with TODAY() for dynamic calculations
- Use YEAR for fiscal/ISO year logic
- Use YEAR with EDATE/EOMONTH for period analysis
YEAR is your date‑extraction anchor — perfect for reporting, grouping, validation, and building robust date‑driven workflows.
Related Patterns and Alternatives ▾
- Use MONTH and DAY for other components
- Use DATE to construct dates
- Use DATEVALUE for text conversion
- Use NOW and TODAY for dynamic values
- Use YEARFRAC for fractional year calculations
By mastering YEAR and its companion functions, you can build powerful, reliable, and fully structured date‑analysis workflows in LibreOffice Calc.