Understanding the result
The first result gives the day number (1 for 1 January) out of the length of the year, with the number of days remaining. The second result takes a year and a day number and gives the calendar date it falls on.
What is a day number of the year?
The day number of the year, also called the ordinal date, counts days from 1 January. 31 December is day 365 in a common year and 366 in a leap year. Ordinal dates such as 2024-060 are part of ISO 8601 and are common in logs, scientific data and manufacturing codes.
It is not the same as the Julian day number used in astronomy, which counts days continuously from 4713 BC.
How it works
The day number is the difference between the date and 1 January of the same year, plus one. Going the other way, the day number minus one is added to 1 January. Both use exact calendar arithmetic, so leap years shift every date after 28 February by one day.
A day number of 366 is accepted only in leap years.
Examples
1 March in a leap and a common year
1 March 2024 is day 61 because February has 29 days. 1 March 2023 is day 60.
Day 100 of 2024
9 April 2024: January has 31 days, February 29, March 31, which is 91 in total, plus 9 more.
The last day of the year
31 December is day 366 in 2024 and day 365 in 2025.
Things to keep in mind
- Day numbers after 28 February differ by one between leap and common years, so a stored day number should be kept with its year.
- Ordinal dates in the "YYYY-DDD" ISO 8601 format use three digits, for example 2024-060.
- This is a calendar day number. It is not a Julian day number, which is a different, continuous count used by astronomers.