# YEAR formula generator

> Describe what you need and get a YEAR formula for Excel and Google Sheets, run on real data before you copy it. Plus 8 tested YEAR examples.

Source: https://spreadsheetpractice.com/tools/formula-generator/year · Updated October 29, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

YEAR returns the four-digit year from a date.

Describe the task at [YEAR formula generator](https://spreadsheetpractice.com/tools/formula-generator/year) and get a YEAR formula for Excel and Google Sheets, tested on real data.

## Tested YEAR examples

### Extract the year from a date

`=YEAR(B2)`

Excel. Result on the sample sheet: 5 rows (C2:C6). [See it and try it](https://spreadsheetpractice.com/formulas/extract-the-year-from-a-date)

### Get the day of the year from a date

`=A2-DATE(YEAR(A2),1,0)`

Excel. Result on the sample sheet: 5 rows (B2:B6). [See it and try it](https://spreadsheetpractice.com/formulas/day-of-the-year)

### Calculate the days left in the year

`=DATE(YEAR(A2),12,31)-A2`

Excel. Result on the sample sheet: 5 rows (B2:B6). [See it and try it](https://spreadsheetpractice.com/formulas/days-left-in-the-year)

### Filter data by month

`=FILTER(A2:E11,(MONTH(B2:B11)=MONTH(H1))*(YEAR(B2:B11)=YEAR(H1)))`

Excel. Result on the sample sheet: 4 rows (G3:K6). [See it and try it](https://spreadsheetpractice.com/formulas/filter-data-by-month)

### Convert a date to text

`=TEXT(A2,"yyyy-mm-dd")`

Excel. Result on the sample sheet: 5 rows (B2:B6). [See it and try it](https://spreadsheetpractice.com/formulas/convert-a-date-to-text)

### Calculate a year-to-date (YTD) total

`=SUMIFS(C2:C10,A2:A10,">="&DATE(YEAR(F1),1,1),A2:A10,"<="&F1)`

Excel. Result on the sample sheet: $15,580. [See it and try it](https://spreadsheetpractice.com/formulas/year-to-date-total)

### Sum by year

`=SUMIFS($C$2:$C$10,$A$2:$A$10,">="&DATE(E2,1,1),$A$2:$A$10,"<="&DATE(E2,12,31))`

Excel. Result on the sample sheet: 3 rows (F2:F4). [See it and try it](https://spreadsheetpractice.com/formulas/sum-by-year)

### Sum by fiscal year

`=SUMPRODUCT((YEAR(EDATE($A$2:$A$9,6))=E2)*$C$2:$C$9)`

Excel. Result on the sample sheet: 2 rows (F2:F3). [See it and try it](https://spreadsheetpractice.com/formulas/sum-by-fiscal-year)

## Questions

### What does the YEAR formula generator do?

You describe the task in plain English, and it writes the formula, using YEAR where that's the right tool, for your table or a sample one. The formula is run in our engine in Excel and Google Sheets mode before you see it, so you get its result, not just a guess.

### What does YEAR do?

YEAR returns the four-digit year from a date.

### Can I learn to write YEAR formulas myself?

Yes. Each example below opens a page where you try the formula in a live grid and it's checked as you go, and the YEAR function page has a practice exercise.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
