← All how-to recipes

How to get the year, month, or day from a date

✓ Verified in LibreOffice 25.8.7.3

Split a date into its parts — for grouping by year, filtering by month, or rebuilding dates.

The formula

AppFormulaNotes
Excel=YEAR(A2)MONTH(A2) gives 1-12, DAY(A2) gives 1-31. DATE(y,m,d) reassembles them.
Google Sheets=YEAR(A2)Identical.
LibreOffice Calc=YEAR(A2)Identical.

How it works

YEAR, MONTH, and DAY each return a plain number from a date (the verification packs all three into 20260723 to prove each one). They're the building blocks for grouping (sum by year), conditions (MONTH(A2)=7), and date surgery — e.g. "same day next year" is DATE(YEAR(A2)+1,MONTH(A2),DAY(A2)). If they return #VALUE!, your "date" is text — convert it first (see the convert-text-to-date recipe).

Verified, not just documented

We ran =YEAR(DATE(2026,7,23))*10000+MONTH(DATE(2026,7,23))*100+DAY(DATE(2026,7,23)) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 20260723 — exactly the expected result. Every formula here is confirmed by actually executing it.