Ordinal date


An ordinal date is a calendar date typically consisting of a year and an ordinal number, ranging between 1 and 366, representing the multiples of a day, called day of the year or ordinal day number. The two parts of the date can be formatted as "YYYY-DDD" to comply with the ISO 8601 ordinal date format. The year may sometimes be omitted, if it is implied by the context; the day may be generalized from integers to include a decimal part representing a fraction of a day.

Nomenclature

Ordinal date is the preferred name for what was formerly called the "Julian date" or, or, which still seen in old programming languages and spreadsheet software. The older names are deprecated because they are easily confused with the earlier dating system called 'Julian day number' or, which was in prior use and which remains ubiquitous in astronomical and some historical calculations.
The U.S. military sometimes uses a system they call the "Julian date format", which indicates the year and the day number. For example, "11 December 1999" can be written as "1999345" or "99345", for the 345th day of 1999.

Calculation

Computation of the ordinal day within a year is part of calculating the ordinal day 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.
In the following text, several algorithms for calculating the ordinal day are presented. The inputs taken are integers, and, for the year, month, and day numbers of the Gregorian or Julian calendar date.

Trivial methods

The most trivial method of calculating the ordinal day involves counting up all days that have elapsed per the definition:
  1. Let O be 0.
  2. From, add the length of month to O, taking care of leap year according to the calendar used.
  3. Add d to O.
Similarly trivial is the use of a lookup table, such as the one referenced.

Zeller-like

The table of month lengths can be replaced following the method of encoding the month-length variation in Zeller's congruence. As in Zeller, the is changed to if. It can be shown that for a month-number, the total days of the preceding months is equal to. As a result, the March 1-based ordinal day number is.
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. This is similar to encoding of the month offset in Zeller's congruence. As is 30.6, the sequence oscillates in the desired pattern with the desired period 5.
To go from the March 1 based ordinal day to a January 1 based ordinal day:
  • For , where is a function returning 0 or 1 depending whether the input is a leap year.
  • For January and February, two methods can be used:
  • # The trivial method is to skip the calculation of and go straight for for January and for February.
  • # The less redundant method is to use, where 306 is the number of dates in March through December. This makes use of the fact that the formula correctly gives a month-length of 31 for January.
"Doomsday" properties:
With and gives
giving consecutive differences of 63 for 3, 4, 5, and 6, i.e., between 4/4, 6/6, 8/8, 10/10, and 12/12.
and gives
and with m and d interchanged
giving a difference of 119 for , and also for .

Table

For example, the ordinal date of April 15 is in a common year, and 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.
  • Day 100 of a common year:
  • Day 200 of a common year:
  • Day 300 of a leap year:

    Helper conversion table

ord.
date
comm.
year
leap
year
11020 Apr19 Apr
12030 Apr29 Apr
1211 May30 Apr
1222 May1 May
13010 May9 May
14020 May19 May
15030 May29 May
1521 Jun31 May
1532 Jun1 Jun
1609 Jun8 Jun
17019 Jun18 Jun
18029 Jun28 Jun
1821 Jul30 Jun
1832 Jul1 Jul
1909 Jul8 Jul

ord.
date
comm.
year
leap
year
20019 Jul18 Jul
21029 Jul28 Jul
2131 Aug31 Jul
2142 Aug1 Aug
2208 Aug7 Aug
23018 Aug17 Aug
24028 Aug27 Aug
2441 Sep31 Aug
2452 Sep1 Sep
2507 Sep6 Sep
26017 Sep16 Sep
27027 Sep26 Sep
2741 Oct30 Sep
2752 Oct1 Oct
2807 Oct6 Oct

ord.
date
comm.
year
leap
year
29017 Oct16 Oct
30027 Oct26 Oct
3051 Nov31 Oct
3062 Nov1 Nov
3106 Nov5 Nov
32016 Nov15 Nov
33026 Nov25 Nov
3351 Dec30 Nov
3362 Dec1 Dec
3406 Dec5 Dec
35016 Dec15 Dec
36026 Dec25 Dec
36531 Dec30 Dec
36631 Dec