Ordinal Day of Year
Day-of-year number (1–366) for a given date.
Formula
Variables
Example
March 1 in a leap year ⇒ N = 61
How it works
This formula converts a calendar date into its position in the year, counting January 1 as day 1, February 1 as day 32, and so on. The floor expressions estimate how many days have already passed in earlier full months, while the leap-year adjustment fixes the shift caused by February having 29 days in leap years. It is a compact shortcut that avoids manually adding the lengths of all earlier months.
When to use it
Use this when you need the day number within a year for programming, astronomy, scheduling, or converting dates to a serial count. It is especially useful in problems where dates must be compared or grouped by their position in the year rather than by month and day.
Worked example, step by step
Find the ordinal day number for September 14 in a common year. M = 9, D = 14, k = 2 N = floor((275M)/9) - k·floor((M+9)/12) + D - 30 N = floor((275×9)/9) - 2·floor((9+9)/12) + 14 - 30 N = floor(275) - 2·floor(18/12) + 14 - 30 N = 275 - 2·1 + 14 - 30 N = 257 So September 14 is the 257th day of the year.
Common mistakes to avoid
- Using k = 1 for a common year and k = 2 for a leap year, which reverses the correction
- Forgetting that the floor function drops any decimal part before continuing
- Mixing up the month number and the day number when substituting into the formula
Did You Know?
Ordinal dates (e.g. 2024-061) appear on aviation and manufacturing labels where a compact date is handy.
Share this formula
More in Time & Calendar
View allLeap Year Rule
BasicTests whether a Gregorian year has 366 days.
Clock Hand Angle
BasicAngle between the hour and minute hands of an analog clock.
Zeller's Congruence
AdvancedFinds the day of the week for any Gregorian date.
Day of the Week from a Birthdate
IntermediateGauss's weekday formula — find which day of the week any birthdate fell on.
Julian Day Number
AdvancedContinuous day count used by astronomers to compare dates.
Days Between Two Dates
IntermediateNumber of days separating two calendar dates.