How to Use YEAR Function in Excel: Extract Year from Date
Use the
YEAR function in Excel to get the year part from a date. Enter =YEAR(date) where date is a cell with a date or a date value, and Excel returns the year as a number.Syntax
The YEAR function extracts the year from a date value.
- date: The date from which you want to get the year. This can be a cell reference containing a date or a date value.
excel
=YEAR(date)
Example
This example shows how to extract the year from a date in cell A1. If A1 contains 12/25/2023, the formula returns 2023.
excel
=YEAR(A1)
Output
2023
Common Pitfalls
Common mistakes include:
- Using text that looks like a date but is not recognized as a date by Excel. The
YEARfunction will return an error or wrong result. - Passing a number that is not a valid date serial number.
- Forgetting to use a valid date format in the cell.
Correct usage requires the input to be a valid Excel date.
excel
=YEAR("2023-12-25") <em>Correct usage with date string recognized by Excel</em> =YEAR("Not a date") <em>Wrong usage, returns error</em>
Quick Reference
| Function | Description | Example | Result |
|---|---|---|---|
| YEAR(date) | Extracts year from date | =YEAR("1/1/2024") | 2024 |
| YEAR(A1) | Extracts year from date in cell A1 | A1=7/4/2022 | 2022 |
Key Takeaways
Use YEAR(date) to get the year number from a valid date in Excel.
Ensure the input is a valid date, not just text that looks like a date.
YEAR returns a four-digit year as a number.
You can use YEAR with cell references or date values directly.
Common errors happen when the input is not recognized as a date.