How to extract the year from a date in Excel
Formula (Excel and Google Sheets)
=YEAR(B2)Use =YEAR(B2). It returns the four-digit year as a number; MONTH and DAY return the other parts.
- Result on the example
- one result per row in
C2, filled down toC6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in C2, filled down to C6. Change any input and the result updates, or edit the formula to experiment.
How it works
YEAR returns the year of a date as a number, ready for grouping, COUNTIF or a pivot table. MONTH and DAY work the same way for the month (1 to 12) and the day (1 to 31).
=YEAR(B2)Result2019
B26/30/2019The value in B2.
YEAR(B2)2019YEAR: Year of a date.- serial_number
B26/30/2019
- serial_number
In Google Sheets
The same formula works in Google Sheets: =YEAR(B2). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =TEXT(B2,"yyyy") | 2019, 2022, 2024…Different result | The year as text, for labels. Text, not a number. |
Common mistakes
- If the result shows as a date like 7/11/1905, the cell has a date format. Format it as a number or General.
- YEAR on text that doesn't look like a date returns #VALUE!. Convert the text first.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Extract the year from a date
C2, return the year of the hire date, and fill down to C6.Questions
How do I get the month or the day?
=MONTH(B2) returns 1 to 12 and =DAY(B2) returns 1 to 31.
How do I count the hires per year?
=SUMPRODUCT(--(YEAR(B2:B6)=2024)), or COUNTIFS between January 1 and December 31.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.