Staaarter

Find Day of the Year

Converts a calendar date into its ordinal day-of-year number, counting from January 1 as day 1, with correct handling of leap years so December 31 always resolves to 365 or 366 as appropriate. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
date-calculationcalendar

Overview

Introduction

Every calendar date has a position within its year, counted as a single ordinal number rather than a month and day pair. This is useful in scheduling systems, log file naming, and scientific data logging.

This tool takes a standard calendar date and returns that ordinal day number, correctly accounting for leap years along the way.

What Is Find Day of the Year?

A day-of-year finder converts a YYYY-MM-DD date into a single number from 1 to 366 representing how many days into the year that date falls, inclusive of the date itself.

It's the same concept behind the "ordinal date" form of ISO 8601, just without the year prefix attached to the output.

How Find Day of the Year Works

The date is parsed and validated as a real calendar date in UTC, rejecting anything that isn't a genuine YYYY-MM-DD value, like February 30.

The tool then measures the whole-day distance between January 1 of that year and the entered date, and adds 1 so January 1 itself reports as day 1.

When To Use Find Day of the Year

Use it when a system, spreadsheet, or file naming convention expects a day-of-year number instead of a month and day.

It's also handy for quickly checking how far into the year a date falls, or for verifying a leap year's effect on later dates.

Features

Advantages

  • Correctly accounts for leap years using real calendar math rather than a fixed 365-day assumption.
  • Uses UTC-based date arithmetic, so there is no risk of an off-by-one error from local time zone daylight saving shifts.

Limitations

  • Only accepts a single strict YYYY-MM-DD date per run, not free-form date text.
  • Does not report the astronomical Julian day number, only the everyday ordinal-date sense of "day of year".

Examples

A date partway through the year

Input

2026-08-05

Output

217

January through July 2026 total 212 days, plus 5 days into August, making August 5 the 217th day of 2026.

The last day of a leap year

Input

2028-12-31

Output

366

2028 is a leap year (divisible by 4, not by 100), so it has 366 days, and December 31 is the final one.

Best Practices & Notes

Best Practices

  • Double check the year when working near December 31 or January 1, since the day number resets to 1 at the start of every new year.
  • Remember that the same calendar date can be a different day number in different years, one day higher after February in a leap year compared to the year before or after it.

Developer Notes

The date is parsed with a strict YYYY-MM-DD regex, then round-tripped through Date.UTC to confirm it represents a real calendar date, rejecting invalid combinations like 2026-02-30 that JavaScript's Date would otherwise silently roll forward. The day number itself is `Math.round((dateUtcMs - yearStartUtcMs) / 86400000) + 1`, computed entirely in UTC milliseconds so no local time zone or daylight saving transition can shift the result by a day.

Find Day of the Year Use Cases

  • Naming log files or backups with a Julian-style day-of-year suffix
  • Checking scheduling or billing systems that store dates as an ordinal day number
  • Classroom or homework exercises on calendar arithmetic and leap years

Common Mistakes

  • Assuming every year has exactly 365 days when calculating a day number by hand, which is off by one for any date after February 28 in a leap year.
  • Entering a date in a non-ISO format like MM/DD/YYYY, which this tool rejects rather than guessing the intended date.

Tips

  • Use Find Date by the Day of the Year to go the other direction, from a day number back to a calendar date.
  • Pair with Find Week of the Year when you need both the ordinal day and the ISO week number for the same date.

References

Frequently Asked Questions