Date and time

Day of the year calculator

Convert a calendar date into its position within the year. January 1 is day 1, and the final day is 365 or 366 depending on leap status.

Enter your values

Your results

Day number in year
—

How we got this result: The page substitutes your current entries into this rule: Subtract UTC January 1 from the chosen UTC date, divide by one day, and add 1.

How to use this calculator

  1. Enter date.
  2. Review the assumptions and units shown beside the fields.
  3. Read the live result, calculation note, and worked examples before using the answer.

Placing a date on the year's number line

The day of year, also called an ordinal day number, identifies a date's position within one calendar year. January 1 is day 1. Each later valid date increments the count by one until December 31, which is day 365 in a common year or day 366 in a leap year.

The year is essential context. March 1, 2025 is day 60, while March 1, 2024 is day 61 because leap-year February contains an additional day. A standalone value such as day 60 does not identify a unique calendar date without a year, and its month-day interpretation can change across leap status.

This number is a position, not a count of complete days elapsed. On January 1, zero complete days have passed since the beginning of the year, but the date occupies position 1. Confusing those two meanings creates the common off-by-one error.

Summing complete months and the current day

The library function calculates the result by adding the lengths of all complete months before the chosen month, then adding the day of the month. For a common year, the month lengths are 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, and 31. In a leap year, February has 29 instead of 28.

For July 1, 2025, the completed months contribute 31 + 28 + 31 + 30 + 31 + 30 = 181 days. Adding the current day gives 182. The function returns 182. This addition method avoids time-zone and daylight-saving complications because it works from calendar components rather than elapsed clock milliseconds.

An equivalent conceptual method for normalized UTC dates is to subtract UTC January 1, divide by one day, and add 1. The direct library implementation, however, uses month totals. Both approaches agree for valid Gregorian dates when applied consistently. The input must represent a real date; arithmetic on an impossible date is not a meaningful calendar result.

February 29 and the leap-year shift

In 2024, January contributes 31 days and February 29 contributes another 29 within its month, so February 29 is day 60. The next date, March 1, is day 61. In 2025 there is no February 29; March 1 follows 31 January days and 28 February days, making it day 60.

The additional leap day affects dates from February 29 onward. A January date has the same ordinal position in a common or leap year. For month-day dates after February, the leap-year ordinal is one larger. December 31 is therefore day 366 in 2024 and day 365 in 2025.

It is incorrect to describe February 29 in a non-leap year as having a shifted day number. That calendar date does not exist in that year. When comparing annual records, decide whether leap day should be omitted, treated separately, or mapped under a stated domain rule rather than pretending the invalid date is present.

The complete Gregorian leap-year rule

A Gregorian year is a leap year when it is divisible by 4, except that a year divisible by 100 is not a leap year unless it is also divisible by 400. The century exceptions are necessary for correct dates around years such as 1900, 2000, 2100, and 2400.

The function classifies 2000 and 2400 as leap years because both are divisible by 400, so December 31 is day 366 in each. It classifies 1900 and 2100 as common years because they are divisible by 100 but not by 400, so December 31 is day 365 in each.

The shortcut 'every fourth year is a leap year' works for many nearby years but fails at most century boundaries. When a calculation must remain valid across a broad range, use the complete divisibility rule rather than a remembered four-year pattern.

Avoiding the off-by-one error

Subtracting January 1 from a date counts intervals between dates. For January 1 itself, that difference is zero. Day-of-year numbering instead counts positions inclusively, so one must be added to an elapsed-day difference. Without that adjustment, every result would be one too small: January 1 would be 0, February 29, 2024 would be 59, and December 31, 2024 would be 365.

The month-sum implementation builds the inclusive convention in directly by adding the current day number. For January 1, there are no completed prior months and the day component is 1, so the result is 1. For February 29, there are 31 days in completed January plus day 29, giving 60.

When comparing two ordinal day numbers in the same year, subtraction gives the number of day boundaries between them. If one milestone is day 180 and another is day 240, the difference is 60 days. If a separate task asks for an inclusive count containing both endpoints, it would add one and report 61 calendar dates. State which convention the question requires.

Day of year versus week number and date difference

A day-of-year value locates one date inside its calendar year. A date-difference calculation measures the distance between two dates and can cross year boundaries. Subtracting ordinal values works directly only when both dates belong to the same year and the same endpoint convention is intended.

A week number answers another question. ISO week numbering groups dates into Monday-to-Sunday weeks, and an ISO week-year can differ near the beginning or end of a calendar year. Dividing an ordinal day by seven does not reproduce the full ISO week rule. Use a week-number calculation when the output must be an ISO week.

Ordinal-date notation often combines the year with a three-digit day, such as a conceptual year-day pair. The year component prevents ambiguity. The calculator returns the numeric day position; any required formatting, padding, or external data standard should be applied separately according to that standard's documented rules.

Validating inputs and month boundaries

Meaningful results require a valid Gregorian calendar date in year-month-day form. Month and day ranges must be checked before relying on the arithmetic: April has no day 31, February has no day 30, and February 29 is valid only in a leap year. The small library function focuses on summing components and should not be treated as a comprehensive date validator.

Known boundaries provide useful tests. January 1 must return 1. February 29, 2024 must return 60. March 1 must return 61 in 2024 and 60 in 2025. December 31 must match the year's length: 366 for 2024 and 365 for 2025. If any of those checks fails, inspect the parsed year, month, day, and leap rule.

Consistent formatting also prevents ambiguous interpretation. A numeric date such as 03/04 can mean different month-day orders in different locales, while 2025-03-04 identifies the components explicitly. The calculator's date control and library convention use year-month-day ordering.

Using ordinal days with clear year context

Ordinal days simplify comparisons within one year because varying month lengths are already absorbed into the count. A milestone on day 240 follows one on day 180 by 60 days, regardless of which month boundaries lie between them. This can be useful in logs, schedules, and datasets when the year is stored alongside the value.

The count restarts every January 1. Day 365 of one year and day 1 of the next are adjacent calendar dates, but subtracting 1 − 365 does not give their actual distance. Cross-year calculations need the calendar years and their lengths, or a dedicated date-difference function.

For reproducibility, retain the original date as well as the ordinal value when possible. The date makes the input auditable, while the day number makes within-year ordering convenient. Confirm leap status and validity, then use the ordinal as the compact result it is rather than as a replacement for all calendar information.

Reference and example table

CaseMeaning
Example 1January 1 is day 1.
Example 2February 29, 2024 is day 60.
Example 3December 31 is day 365 in 2025 and day 366 in 2024.

Frequently asked questions

What does day of year mean?

It is a date's one-based position within its calendar year. January 1 is day 1, and December 31 is day 365 or 366 depending on leap status.

How does the library calculate the day number?

It adds the lengths of all complete months before the selected month, adjusts February for leap status, and then adds the current day of the month.

What day of the year is February 29, 2024?

It is day 60: January contributes 31 days and February 29 contributes 29 more.

What day is March 1 in common and leap years?

March 1 is day 60 in a common year such as 2025 and day 61 in a leap year such as 2024.

Why is 1900 not a leap year while 2000 is?

Century years must be divisible by 400 to be leap years. The year 1900 is not divisible by 400, while 2000 is.

Why is January 1 day 1 instead of day 0?

Day-of-year is an inclusive position. Zero full days have elapsed at January 1, but that date occupies the first position in the year's sequence.

Can I subtract two day-of-year values?

Yes for dates in the same year when you want the interval between their positions. Cross-year differences need the years and calendar lengths, and inclusive counts use a different endpoint convention.

Does the day number uniquely identify a date?

Not by itself. The year is required because the count restarts annually and leap status changes the month-day corresponding to values after February.