Ordinal date


An ordinal date is a calendar date typically consisting of a year and a day of the year ranging between 1 and 366, though year may sometimes be omitted. The two numbers can be formatted as YYYY-DDD to comply with the ISO 8601 ordinal date format.

Calculation

Computation of the ordinal date within a year is part of calculating the ordinal date throughout the years from a reference date, such as the Julian date. It is also part of calculating the day of the week, though for this purpose modulo-7 simplifications can be made.
For these purposes, it is convenient to count January and February as month 13 and 14 of the previous year, for two reasons: the shortness of February and its variable length. In that case, the date counted from 1 March is given by
which can also be written
or
with m the month number and d the date. is the floor function.
The formula reflects the fact that any five consecutive months in the range March–January have a total length of 153 days, due to a fixed pattern 31–30–31–30–31 repeating itself twice.
"Doomsday" properties:
For and we get
giving consecutive differences of 63 for n = 2, 3, 4, 5, and 6, i.e., between 4/4, 6/6, 8/8, 10/10, and 12/12.
For and we get
and with m and d interchanged
giving a difference of 119 for n = 2, and also for n = 3.
The ordinal date from 1 January is:
or equivalently, the ordinal date from 1 March of the previous year minus 306.

Modulo 7

Again counting January and February as month 13 and 14 of the previous year, the date counted from 1 March is modulo 7 equal to
with m the month number and d the date.
Calculation can be done starting with January 1 mathematically without if statements if we take advantage of min and max algebraic logic
MAX is

MIN is

provided the month day and year
//if Jan is a full month
//if Feb is a full month
//if Mar is a full month
//if Apr is a full month
//if May is a full month
//if June is a full month
//if July is a full month
//if Aug is a full month
//if Sept is a full month
//if Oct is a full month
//if Nov is a full month
//days of current month
//leap year logic
//only count a leap year if date is >=3rd month //leap year logic
example of Aug 24th 2016 is

Table

For example, the ordinal date of April 15 is 90 + 15 = 105 in a common year, and 91 + 15 = 106 in a leap year.

Month–day

The number of the month and date is given by
the term can also be replaced by with the ordinal date.