Take a date apart with YEAR, MONTH, DAY and WEEKDAY
Dates and times6 min
Builds on Add and subtract days with dates and Decide with IF.
The sales manager wants order totals by month and by quarter, and facilities pays a supplement for weekend deliveries. Both answers are already inside the order dates.
How it works
YEAR, MONTH and DAY each read one part of a date and return it as a plain number. For Nov 29, 2026, YEAR gives 2026, MONTH gives 11 and DAY gives 29. Picture the date as a stamp with three fields printed on it, where each function reads one field. The results are ordinary numbers, so they work in IF tests and in SUMIF.
WEEKDAY returns the day of the week as a number. Its optional second argument, the return type, decides how the days are numbered, and the default catches people out: Sunday is 1 and Saturday is 7, so the weekend sits at both ends of the week.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Return type | Monday | Friday | Saturday | Sunday |
| 2 | 1, or left out | 2 | 6 | 7 | 1 |
| 3 | 2 | 1 | 5 | 6 | 7 |
| 4 | 3 | 0 | 4 | 5 | 6 |
With return type 2, Saturday and Sunday are the only days above 5.
Example
Reports often need a key that sorts by year and then by month. For Dec 12, 2026 in F2:
=YEAR(F2)*100+MONTH(F2)It returns 202612, which sorts after 202611 and before 202701.
Common mistakes
=WEEKDAY(F2)>5uses the default numbering, where Friday is 6 and Sunday is 1, so it flags Fridays and Saturdays. Give the return type.=YEAR(F2)can show Jul 18, 1905 when Excel gives the new cell a date format: the cell holds 2026, read as a date. Format the cell as General.- MONTH returns 12 for every December. When the data covers more than one year, group by year and month together.
In short
- YEAR, MONTH and DAY return plain numbers to test and group by.
- WEEKDAY numbers the days according to its return type. With 2, Monday is 1 and Sunday is 7.
- Format the results as numbers, not dates.
Practice
4 exercises · free with an account