ThisCalculator

Everyday

Get Date from Day Number: How to Convert

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Get Date from Day Number: How to Convert

This calculator converts a day number (1–365 or 366 for leap years) into the corresponding calendar date. You enter the day number and the year, and you get back the month, day, and weekday. The calculation uses the standard Gregorian calendar rules, including leap years.

Formula

The conversion from a day number to a date is the inverse of counting days from January 1. For a given year Y and day number D (where January 1 is day 1), the date is found by subtracting the lengths of months until the remainder falls within a month.

Let M be the month (1–12) and d be the day within that month. The algorithm is:

  1. Start with remaining = D and M = 1.
  2. For each month, subtract the number of days in that month from remaining.
  3. When the next subtraction would make remaining ≤ 0, stop. The current month is M and d = remaining.

Days in month for the Gregorian calendar:

  • January: 31
  • February: 28 (29 if leap year)
  • March: 31
  • April: 30
  • May: 31
  • June: 30
  • July: 31
  • August: 31
  • September: 30
  • October: 31
  • November: 30
  • December: 31

A leap year occurs if the year is divisible by 4, except if it is divisible by 100, unless it is also divisible by 400. For example, 2000 was a leap year, 1900 was not, and 2024 is.

Worked Example

Using the default values: day number 100 in the year 2024.

  1. Remaining = 100, M = 1.
  2. Subtract January (31): remaining = 100 – 31 = 69. M = 2.
  3. Subtract February (29, because 2024 is a leap year): remaining = 69 – 29 = 40. M = 3.
  4. Subtract March (31): remaining = 40 – 31 = 9. M = 4.
  5. Now remaining = 9, which is ≤ 31, so the date is April 9.

So day 100 of 2024 is April 9, 2024. The weekday is Tuesday (calculated using Zeller’s congruence or a known reference).

When to Use This Conversion

You might need this in programming (e.g., converting a day-of-year from a date library), in data analysis (e.g., time series with day numbers), or in logistics (e.g., “day 200” in a production schedule). It’s also handy for understanding ordinal dates in calendars.

Many spreadsheet programs have a function like DATE(year,1,1) + day_number - 1 to get the date. This calculator replicates that logic without needing a spreadsheet.

Common Mistakes and Misconceptions

  • Forgetting leap years: Day 60 is February 29 in a leap year, but March 1 in a common year. Always check if the year is divisible by 4 (with the century exception).
  • Off-by-one errors: January 1 is day 1, not day 0. If you use day 0, you get December 31 of the previous year.
  • Using the Julian calendar: The Gregorian calendar is the standard today, but historical dates before 1582 (or later in some countries) may use the Julian calendar, which has different leap year rules.
  • Day 366 in a non-leap year: This is invalid; the calculator will return an error or a rollover to the next year.

How to Read the Result

The result shows the month name, day, and year. The weekday is also given, which can be useful for planning. For example, if you know day 250 is a weekend, you can schedule accordingly.

Note that the calculator assumes the Gregorian calendar, which is the civil calendar in most of the world. For dates before the adoption of the Gregorian calendar (1582 in some countries, later in others), the result may not match historical records.

Alternative Methods

If you don’t have this calculator, you can:

  • Use a spreadsheet formula: =DATE(year,1,1) + day_number - 1 (Excel, Google Sheets).
  • Use a programming language: Python’s datetime.date(year,1,1) + timedelta(days=day_number-1).
  • Use an online date converter that handles ordinal dates.

These methods all use the same logic, but be careful with time zones if you’re using programming languages that include time components.

Frequently Asked Questions

What is the day number for December 31 in a leap year?

In a leap year, December 31 is day 366. In a common year, it’s day 365. The calculator will accept 366 only for leap years.

How do I convert a date to a day number?

That’s the reverse calculation. You can subtract the date from January 1 of the same year and add 1. For example, February 1 is day 32 in a common year (31 + 1). Many calculators and spreadsheets also do this.

Does this work for years before 1582?

It uses the Gregorian calendar rules, which were introduced in 1582. For earlier years, the Julian calendar was used, so the result may be off by a few days. The calculator allows years from 1583 onward to avoid this ambiguity.

Why is February 29 sometimes day 60 and sometimes day 59?

In a leap year, February 29 is day 60 (31 days in January + 29 days in February). In a common year, February 28 is day 59, and March 1 is day 60. So day 60 is always March 1 in a common year, but February 29 in a leap year.

Can I use this to find the day of the week for any date?

Yes, the calculator also outputs the weekday. It uses Zeller’s congruence or a similar algorithm that works for any Gregorian date. You can verify with a known date, like January 1, 2000, which was a Saturday.

Related

Formula used
in day | Day number | - | 100 | 1
in yr | Year | - | 2024 | 1583
out date | Date | - | date_from_day(day, yr) | 0
out weekday | Weekday | - | weekday_from_day(day, yr) | 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.