How to get the day of the year from a date in Excel
Formula (Excel and Google Sheets)
=A2-DATE(YEAR(A2),1,0)Subtract the last day of the previous year: =A2-DATE(YEAR(A2),1,0) returns 1 to 366.
- Result on the example
- one result per row in
B2, filled down toB6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in B2, filled down to B6. Change any input and the result updates, or edit the formula to experiment.
How it works
DATE(YEAR(A2),1,0) is day 0 of January, which is December 31 of the year before. Subtracting it from the date leaves the day number: 60 for March 1 in a common year, 61 in a leap year.
In Google Sheets
The same formula works in Google Sheets: =A2-DATE(YEAR(A2),1,0). 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 |
|---|---|---|
| =A2-DATE(YEAR(A2),1,1)+1 | 1, 59, 60… | The same, counting from January 1. |
| =TEXT(A2-DATE(YEAR(A2),1,0),"000") | 001, 059, 060…Different result | A three-digit text code like 060, used in Julian dates. Three-digit text. |
Common mistakes
- This is the day of the year, sometimes called the Julian day, but not the astronomical Julian Day Number.
- Format the result as a number, or it inherits the date format.
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.
Get the day of the year from a date
B2, return the day number of the year (1 for January 1) for the date in A2, and fill down to B6.Questions
How do I convert a day number back to a date?
=DATE(2026,1,B2): DATE rolls day 60 into March 1.
How do I make a YYDDD Julian date?
=TEXT(A2,"yy")&TEXT(A2-DATE(YEAR(A2),1,0),"000").
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.