Day of the Year

/
Jan 1 Dec 31
Days remaining
Week number
Quarter
Leap year
Season
Zodiac
Look up a date
Look up a day number

What Is the Day of the Year?

The day of the year — also called the ordinal date or the day number — is the position of a date within its calendar year, counting from 1 on January 1. December 31 is day 365, or day 366 when the year is a leap year. It replaces a month-and-day pair with a single integer, which makes dates trivial to sort, subtract, and drop into filenames.

Because the count restarts every January 1, a day number only means something alongside its year: day 200 of 2026 and day 200 of 2027 are different dates.

ISO 8601 Ordinal Dates

ISO 8601 defines an official written form for ordinal dates: YYYY-DDD, where the day number is always zero-padded to three digits. September 1, 2026 is 2026-244, and January 1 is 2026-001. The basic, hyphen-free form is 2026244. Valid day numbers run from 001 to 365, or to 366 in a leap year.

This is a real, parseable date format rather than a local convention. Python reads it with datetime.strptime(s, "%Y-%j"), and many logging, telemetry, and data-interchange formats accept it interchangeably with the familiar YYYY-MM-DD calendar form.

Leap Years and February 29

A year is a leap year if it is divisible by 4, except years divisible by 100, unless they are also divisible by 400. So 2024 and 2000 are leap years, while 1900 and 2100 are not. Leap years have 366 days, and every date from March 1 onward carries a day number one higher than it would in a common year.

That one-day shift is where most day-of-year bugs come from. Hard-coding "day 365 is December 31", or building a fixed table of month offsets, breaks every four years. If you compare day numbers across years, convert back to real dates first, or at the very least branch on the leap-year test.

Day of Year vs. Julian Day

These are two different things that unfortunately share a name.

Ordinal date (1–366)

The day of the year is frequently called a "Julian date" in manufacturing, aviation, food packaging, and mainframe systems, where a code like 26244 means year 2026, day 244. It resets every January.

Julian Day Number (astronomical)

The astronomical Julian Day Number is a continuous count of days since noon UTC on January 1, 4713 BC in the proleptic Julian calendar. September 1, 2026 is Julian Day 2461285. It never resets, which is precisely what astronomers want for computing intervals that span centuries and calendar reforms. The quick test: a value in the millions is a true Julian Day; a value between 1 and 366 is an ordinal date.

How to Calculate the Day of the Year in Code

One gotcha: %j pads to three digits (001), while most language accessors return a plain integer (1). Pick one and be consistent, especially if the values end up in filenames that you expect to sort.

Where Ordinal Dates Are Used

Day of Year vs. Week Number

ISO 8601 week numbers answer a nearby question under different rules. Weeks start on Monday, and week 1 is the week containing the year's first Thursday — so January 1 can land in week 52 or 53 of the previous year, and a year has either 52 or 53 weeks. This is why the week number shown above will not always equal the day number divided by 7. Use ordinal dates when you need to name an exact day, and week numbers when you need to group by business week.

Frequently Asked Questions

What is the day of the year?

It is the position of a date within its year, counting from 1 on January 1 up to 365, or 366 in a leap year. It is also called the ordinal date or the day number. March 1 is day 60 in a common year and day 61 in a leap year.

What is the ISO 8601 ordinal date format?

ISO 8601 writes ordinal dates as YYYY-DDD, with the day number zero-padded to three digits: 2026-001 for January 1 and 2026-244 for September 1. The hyphen-free basic form is 2026244. Valid day numbers run from 001 to 365, or to 366 in a leap year.

How many days are in a year?

365 in a common year and 366 in a leap year. A year is a leap year if it is divisible by 4, except years divisible by 100, unless they are also divisible by 400. So 2024 and 2000 are leap years, while 1900 and 2100 are not.

Is the day of the year the same as the Julian date?

No, although the terms get mixed up constantly. The day of the year runs from 1 to 366 and resets every January. The astronomical Julian Day Number is a continuous count of days since 4713 BC and is currently over 2.46 million. Industry systems that say Julian date almost always mean the ordinal day number.

How do I calculate the day of the year in Python or Excel?

In Python, use date.today().timetuple().tm_yday, or strftime with %j for a zero-padded string. In Excel or Google Sheets, subtract January 1 from the date and add one: =A1-DATE(YEAR(A1),1,1)+1. In a shell, date +%j prints today's day number.

Does February 29 change the day numbers?

Yes. In a leap year February 29 is day 60, and every date from March 1 onward shifts one number later than in a common year. That is why day numbers should never be compared across years without accounting for leap days.

What is the difference between day of year and week number?

Day of year counts individual days from 1 to 366. ISO 8601 week numbers group days into weeks that start on Monday, where week 1 is the week containing the first Thursday of the year. Because of that rule, January 1 can belong to week 52 or 53 of the previous year, and a year can have 53 weeks.