dash–calculator

04 Numbers and Counting

Day of Year Number: How to Find It

Readout 04-0319 · Updated · Standard formula, shown below

Day of Year 74
Days Left in Year
292
Result, rounded to a whole number
Month
3
Input
Day
14
Input
You enter
Month, Day, Year
You get
Day of Year, Days Left in Year
Rounding
0 dp

This page explains what the day of the year number is, how to calculate it for any date, and how to use the calculator below. You enter a month, day, and year (or just a month and day for a non-leap year), and you get back the ordinal number of that day within the year, from 1 for January 1 to 365 (or 366 in a leap year) for December 31.

Formula

The day-of-year number is the count of days that have passed since January 1 of the same year, plus one. For a date in month m, day d, and year y, the formula used here is:

Day of Year = floor((275 × m) / 9) − floor(((m + 9) / 12) × (1 + floor((y − 4 × floor(y / 4) + 2) / 3))) + d − 30

Where:

  • m = month number (1 = January, 12 = December)
  • d = day of the month (1–31)
  • y = full year (e.g., 2024)
  • floor(x) = the largest integer less than or equal to x

This is a compact, non-looping formula that works for both common and leap years. The leap-year adjustment is hidden in the second term: it subtracts 1 for January and February in a leap year, which shifts the day count correctly after February 29.

Worked Example

Using the default values: March 14, 2024. First compute the leap-year flag: floor(2024 / 4) = 506, floor(2024 / 100) = 20, floor(2024 / 400) = 5, so 506 − 20 + 5 = 491. The term inside the second floor is ((3 + 9) / 12) × (1 + floor((2024 − 4 × 506 + 2) / 3)) = (12/12) × (1 + floor((2024 − 2024 + 2) / 3)) = 1 × (1 + floor(2/3)) = 1 × (1 + 0) = 1. Now the first part: floor((275 × 3) / 9) = floor(825 / 9) = floor(91.666…) = 91. Then 91 − 1 + 14 − 30 = 74. So March 14, 2024 is day 74 of the year. The calculator shows 74, and 292 days remain (366 − 74 = 292).

Why the Day of Year Matters

The ordinal day number is used in many practical contexts:

  • Astronomy and meteorology: Scientists track seasonal data by day number rather than calendar date to compare years consistently.
  • Agriculture: Farmers use growing-degree-day calculations that reference the day of year to predict crop stages.
  • Finance and billing: Some interest calculations and invoice cycles use the actual day count, not just month boundaries.
  • Software and data: Many file formats and APIs (like Unix timestamps or ISO week dates) require converting a date to a day number for sorting or comparison.
  • Project planning: Annual schedules often reference “day 200” instead of a specific date to avoid year-specific confusion.

How to Read the Result

The main output is the day number itself. January 1 is always 1. December 31 is 365 in a common year and 366 in a leap year. The second output, “Days Left in Year,” tells you how many days remain after the entered date, excluding that day itself. For example, if today is day 100, there are 265 days left in a common year. This is useful for countdowns or for calculating the fraction of the year elapsed (day / 365 or day / 366).

Common Mistakes and Misconceptions

Three errors appear frequently when people work with day-of-year numbers:

  • Off-by-one at the start: Some people think January 1 is day 0. It is day 1. The count includes the current day.
  • Forgetting leap years: In a leap year, every date after February 28 has its day number increased by 1 compared to a common year. For example, March 1 is day 61 in a common year but day 62 in a leap year.
  • Using a fixed 365-day count: If you divide a day number by 365 to get a fraction of the year, you will be slightly off in leap years. Use 366 for leap years.

Another misconception is that the day of year is the same as the week number. It is not. Week numbers (ISO 8601) count weeks, and week 1 may start in the previous year. Day of year is a straight ordinal count.

Leap Year Rules

A year is a leap year if it is divisible by 4, except that years divisible by 100 are not leap years unless they are also divisible by 400. So 2024 is a leap year (divisible by 4, not by 100), 1900 was not (divisible by 100 but not 400), and 2000 was (divisible by 400). The formula in the calculator handles this automatically. If you are doing the calculation by hand, always check the leap status of the year before adding the extra day.

Alternative Methods

You do not have to use the compact formula. Two other approaches give the same answer:

  • Cumulative month table: Memorize or look up the number of days before each month (Jan: 0, Feb: 31, Mar: 59 or 60, Apr: 90 or 91, etc.), then add the day of the month. For March 14 in a leap year: 31 + 29 + 14 = 74.
  • Spreadsheet functions: In Excel or Google Sheets, the formula =A1-DATE(YEAR(A1),1,1)+1 returns the day of year for a date in cell A1. This is the simplest method if you already have the date in a table.

Each method produces the same result; the calculator above uses the formula version so it works without external software.

Frequently Asked Questions

Is January 1 day 0 or day 1?
Day 1. The day-of-year count starts at 1 for the first day of the year. This matches most scientific and financial conventions.

How does February 29 affect the day number?
In a leap year, February 29 is day 60. The next day, March 1, is day 61, whereas in a common year March 1 is day 60. Every date after February 28 is shifted by one in a leap year.

What is the day of year for December 31?
It is 365 in a common year and 366 in a leap year. The calculator will show the correct value based on the year you enter.

Can I use this for a year before 1582?
The formula assumes the modern Gregorian calendar, which was introduced in 1582. For earlier dates, the Julian calendar had different leap-year rules, so the result may not match historical records.

Why does the formula have that strange 275 and 30 in it?
Those constants are derived from the pattern of month lengths. The term floor(275×m/9) produces the cumulative day count for a year where months are treated as having an average length, and the correction terms adjust for the actual month lengths and leap years. It is a known compact algorithm that avoids looping through each month.

What if I enter an invalid date like February 30?
The calculator does not check the validity of the month-day combination beyond the basic ranges (day 1–31). February 30 would produce a result, but that date does not exist. Always verify that the date you enter is a real calendar date.

Related

Formula used
in mo | Month | - | 3 | 1 | 12
in da | Day | - | 14 | 1 | 31
in yr | Year | - | 2024 | 1 | 9999
out doy | Day of Year | - | floor((275 * mo) / 9) - floor(((mo + 9) / 12) * (1 + floor((yr - 4 * floor(yr / 4) + 2) / 3))) + da - 30 | 0
out rem | Days Left in Year | - | 365 + (1 * (floor(yr / 4) - floor(yr / 100) + floor(yr / 400) - floor((yr - 1) / 4) + floor((yr - 1) / 100) - floor((yr - 1) / 400))) - doy | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More on this panel

The whole Numbers and Counting panel →