Spreadsheet Practice

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 to B6
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.

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

Result1

  1. A21/1/2026

    The value in A2.

  2. YEAR(A2)2026

    YEAR: Year of a date.

    • serial_numberA21/1/2026
  3. DATE(YEAR(A2),1,0)12/31/2025 (46022)

    DATE: Builds a date from parts.

    • yearYEAR(A2)2026
    • month1
    • day0
  4. A2-DATE(YEAR(A2),1,0)1

    The - operator subtracts.

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.

FormulaResultWhen to use it
=A2-DATE(YEAR(A2),1,1)+11, 59, 60…The same, counting from January 1.
=TEXT(A2-DATE(YEAR(A2),1,0),"000")001, 059, 060…Different resultA 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

In 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.