expressed according to ISO 8601 [{{purge|refresh}}] | |
Label1: | Date |
Label2: | Ordinal date |
Data2: | - |
An ordinal date is a calendar date typically consisting of a year and an ordinal number, ranging between 1 and 366 (starting on January 1), representing the multiples of a day, called day of the year or ordinal day number (also known as ordinal day or 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.
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.
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.
The most trivial method of calculating the ordinal day involves counting up all days that have elapsed per the definition:
Similarly trivial is the use of a lookup table, such as the one referenced.[1]
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 (see below) 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 (which would be the same sequence modulo 7) 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:
"Doomsday" properties:
With
m=2n
d=m
O=\left\lfloor63.2n-91.4\right\rfloor
m=2n+1
d=m+4
O=\left\lfloor63.2n-56+0.2\right\rfloor
O=\left\lfloor63.2n-56+119-0.4\right\rfloor
giving a difference of 119 (17 weeks) for (difference between 5/9 and 9/5), and also for (difference between 7/11 and 11/7).
To the day of | 13 Jan | 14 Feb | 3 Mar | 4 Apr | 5 May | 6 Jun | 7 Jul | 8 Aug | 9 Sep | 10 Oct | 11 Nov | 12 Dec | i | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Add | 0 | 31 | 59 | 90 | 120 | 151 | 181 | 212 | 243 | 273 | 304 | 334 | 3 | |
Leap years | 0 | 31 | 60 | 91 | 121 | 152 | 182 | 213 | 244 | 274 | 305 | 335 | 2 | |
Algorithm | 30(m-1)+\left\lfloor0.6(m+1)\right\rfloor-i |
For example, the ordinal date of April 15 is in a common year, and in a leap year.
The number of the month and date is given by
m=\left\lfloorod/30\right\rfloor+1
d=\bmod(od,30)+i-\left\lfloor0.6(m+1)\right\rfloor
\bmod(od,30)
od-30(m-1)
od
m=\left\lfloor100/30\right\rfloor+1=4
d=\bmod(100,30)+3-\left\lfloor0.6(4+1)\right\rfloor=10+3-3=10
April 10.
m=\left\lfloor200/30\right\rfloor+1=7
d=\bmod(200,30)+3-\left\lfloor0.6(7+1)\right\rfloor=20+3-4=19
July 19.
m=\left\lfloor300/30\right\rfloor+1=11
d=\bmod(300,30)+2-\left\lfloor0.6(11+1)\right\rfloor=0+2-7=-5
November - 5 = October 26 (31 - 5).
ord. date | common year | leap year | |
---|---|---|---|
001 | 1 Jan | ||
010 | 10 Jan | ||
020 | 20 Jan | ||
030 | 30 Jan | ||
032 | 1 Feb | ||
040 | 9 Feb | ||
050 | 19 Feb | ||
060 | 1 Mar | 29 Feb | |
061 | 2 Mar | 1 Mar | |
070 | 11 Mar | 10 Mar | |
080 | 21 Mar | 20 Mar | |
090 | 31 Mar | 30 Mar | |
091 | 1 Apr | 31 Mar | |
092 | 2 Apr | 1 Apr | |
100 | 10 Apr | 9 Apr |
ord. date | comm. year | leap year | |
---|---|---|---|
110 | 20 Apr | 19 Apr | |
120 | 30 Apr | 29 Apr | |
121 | 1 May | 30 Apr | |
122 | 2 May | 1 May | |
130 | 10 May | 9 May | |
140 | 20 May | 19 May | |
150 | 30 May | 29 May | |
152 | 1 Jun | 31 May | |
153 | 2 Jun | 1 Jun | |
160 | 9 Jun | 8 Jun | |
170 | 19 Jun | 18 Jun | |
180 | 29 Jun | 28 Jun | |
182 | 1 Jul | 30 Jun | |
183 | 2 Jul | 1 Jul | |
190 | 9 Jul | 8 Jul |
ord. date | comm. year | leap year | |
---|---|---|---|
200 | 19 Jul | 18 Jul | |
210 | 29 Jul | 28 Jul | |
213 | 1 Aug | 31 Jul | |
214 | 2 Aug | 1 Aug | |
220 | 8 Aug | 7 Aug | |
230 | 18 Aug | 17 Aug | |
240 | 28 Aug | 27 Aug | |
244 | 1 Sep | 31 Aug | |
245 | 2 Sep | 1 Sep | |
250 | 7 Sep | 6 Sep | |
260 | 17 Sep | 16 Sep | |
270 | 27 Sep | 26 Sep | |
274 | 1 Oct | 30 Sep | |
275 | 2 Oct | 1 Oct | |
280 | 7 Oct | 6 Oct |
ord. date | comm. year | leap year | |
---|---|---|---|
290 | 17 Oct | 16 Oct | |
300 | 27 Oct | 26 Oct | |
305 | 1 Nov | 31 Oct | |
306 | 2 Nov | 1 Nov | |
310 | 6 Nov | 5 Nov | |
320 | 16 Nov | 15 Nov | |
330 | 26 Nov | 25 Nov | |
335 | 1 Dec | 30 Nov | |
336 | 2 Dec | 1 Dec | |
340 | 6 Dec | 5 Dec | |
350 | 16 Dec | 15 Dec | |
360 | 26 Dec | 25 Dec | |
365 | 31 Dec | 30 Dec | |
366 | 31 Dec |