Skip to content Skip to sidebar Skip to footer

When Do Dates Fall on the Same Weekday Again

Methods to calculate the day of the week

The determination of the mean solar day of the week for any engagement may be performed with a diverseness of algorithms. In addition, perpetual calendars require no calculation by the user, and are essentially lookup tables. A typical application is to calculate the day of the week on which someone was born or a specific event occurred.

Concepts [edit]

In numerical calculation, the days of the week are represented every bit weekday numbers. If Mon is the outset day of the week, the days may exist coded 1 to 7, for Mon through Sunday, as is practiced in ISO 8601. The 24-hour interval designated with 7 may also be counted every bit 0, by applying the arithmetic modulo 7, which calculates the remainder of a number afterwards segmentation by vii. Thus, the number 7 is treated as 0, 8 every bit 1, ix as two, 18 as four and and then on. If Sunday is counted as day 1, then 7 days later (i.e. solar day 8) is likewise a Sun, and 24-hour interval 18 is the same equally 24-hour interval iv, which is a Wednesday since this falls 3 days after Sunday.[a]

Standard Monday Tuesday Wednesday Thursday Fri Sabbatum Lord's day Usage examples
ISO 8601 ane ii 3 4 5 6 seven %_ISODOWI%, %@ISODOWI[]% (4DOS);[ane] DAYOFWEEK() (HP Prime)[2]
0 ane 2 iii 4 5 half-dozen
2 3 4 v 6 7 ane %NDAY OF Week% (NetWare, DR-DOS[3]); %_DOWI%, %@DOWI[]% (4DOS)[i]
one 2 3 4 v six 0 HP financial calculators

The basic approach of nearly all of the methods to summate the day of the calendar week begins past starting from an 'anchor engagement': a known pair (such every bit 1 January 1800 as a Wednesday), determining the number of days between the known day and the solar day that you are trying to determine, and using arithmetic modulo vii to find a new numerical day of the week.

One standard approach is to look up (or calculate, using a known dominion) the value of the first twenty-four hours of the calendar week of a given century, look up (or calculate, using a method of congruence) an aligning for the month, calculate the number of leap years since the start of the century, then add these together along with the number of years since the start of the century, and the day number of the calendar month. Eventually, ane ends upwards with a mean solar day-count to which one applies modulo 7 to decide the twenty-four hours of the week of the date.[4]

Some methods practise all the additions showtime and then cast out sevens, whereas others cast them out at each step, as in Lewis Carroll's method. Either way is quite viable: the one-time is easier for calculators and computer programs, the latter for mental calculation (it is quite possible to exercise all the calculations in i's head with a piddling practice). None of the methods given here perform range checks, and so unreasonable dates will produce erroneous results.

Corresponding days [edit]

Every seventh day in a month has the aforementioned name as the previous:

Twenty-four hours of
the month
d
00 07 14 21 28 0
01 08 15 22 29 i
02 09 16 23 30 ii
03 10 17 24 31 3
04 xi 18 25 4
05 12 nineteen 26 5
06 13 xx 27 6

Corresponding months [edit]

"Corresponding months" are those months within the agenda year that start on the aforementioned twenty-four hours of the week. For example, September and December represent, because 1 September falls on the same day as ane December (every bit there are precisely thirteen 7-day weeks between the two dates). Months can but correspond if the number of days between their first days is divisible by 7, or in other words, if their commencement days are a whole number of weeks apart. For case, February of a common year corresponds to March because Feb has 28 days, a number divisible past vii, 28 days being exactly iv weeks. In a leap year, Jan and February represent to different months than in a mutual year, since adding 29 February means each subsequent calendar month starts a mean solar day later.

January corresponds to October in mutual years and April and July in leap years. February corresponds to March and November in common years and August in jump years. March e'er corresponds to November, Apr ever corresponds to July, and September always corresponds to December. August does not correspond to any other month in a common year. October doesn't correspond to any other month in a leap year. May and June never stand for to any other month.

In the months tabular array beneath, corresponding months accept the same number, a fact which follows straight from the definition.

Common years Bound years All years m
January Oct 0
May one
Feb Aug 2
Feb Mar Nov 3
Jun 4
Sept December 5
Jan Apr July 6

Respective years [edit]

There are seven possible days that a year tin offset on, and bound years will alter the solar day of the week afterward 29 February. This means that there are 14 configurations that a year can have. All the configurations tin can exist referenced past a dominical letter of the alphabet, but as 29 February has no letter allocated to it, a bound yr has two dominical messages, one for January and February and the other (one step back in the alphabetical sequence) for March to December.

2021 is a mutual year starting on Friday, which means that it corresponds to the 2010 calendar year. The commencement ii months of 2021 correspond to the kickoff 2 months of 2016. 2022 is a common yr starting on Saturday, which means that it corresponds to the 2011 calendar yr. The final x months of 2022 stand for to the concluding ten months of 2016. 2023 is a common twelvemonth starting on Sunday, which ways that it corresponds to the 2017 agenda twelvemonth. 2024 is a leap yr starting on Monday, which means that it corresponds to the 1996 calendar twelvemonth. The commencement two months of 2024 correspond to the starting time 2 months of 2018. The last x months of 2024 stand for to the last ten months of 2019.

Each jump year repeats once every 28 years, and every common year repeats once every 6 years and twice every xi years. For case, the final occurrence of a leap year starting on Wednesday was 2020 and the side by side occurrence will be 2048. Too, the side by side common years starting on Fri volition be 2027, 2038, and then 2049. Both of these statements are truthful unless a leap year is skipped, but that volition not happen until 2100.

For details see the table below.

Year of the
century modern 28
y
00 06 12 17 23 0
01 07 12 18 24 1
02 08 13 nineteen 24 2
03 08 14 20 25 3
04 09 15 xx 26 4
04 10 sixteen 21 27 5
05 11 sixteen 22 00 6

Notes:

  • Blackness means all the months of Common Twelvemonth
  • Scarlet means the offset 2 months of Jump Yr
  • Bluish means the terminal 10 months of Leap Year

Corresponding centuries [edit]

Julian century
mod 700
Gregorian century
mod 400[b]
Day
400: 1100 1800 ... 300: 1500 1900 ... Dominicus
300: thousand 1700 ... Monday
200 0900 1600 ... 200: 1800 2200 ... Tue
100 0800 1500 ... Wednesday
700: 1400 2100 ... 100: 1700 2100 ... Thu[c]
600: 1300 2000 ... Fri
500: 1200 1900 ... 000: 1600 2000 ... Sat

"Yr 000" is, in normal chronology, the year ane BC (which precedes Advertising ane). In astronomical year numbering the year 0 comes between 1 BC and AD 1. In the proleptic Julian calendar, (that is, the Julian agenda as information technology would have been if it had been operated correctly from the beginning), 1 BC starts on Thursday. In the proleptic Gregorian calendar, (so chosen because it wasn't devised until 1582), 1 BC starts on Saturday.

Tabular methods to calculate the solar day of the week [edit]

Complete table: Julian and Gregorian calendars [edit]

For Julian dates earlier 1300 and after 1999 the year in the table which differs by an exact multiple of 700 years should be used. For Gregorian dates after 2299, the year in the tabular array which differs by an exact multiple of 400 years should exist used. The values "r0" through "r6" indicate the remainder when the Hundreds value is divided past 7 and 4 respectively, indicating how the series extend in either direction. Both Julian and Gregorian values are shown 1500-1999 for convenience. Bold figures (e.g., 04) denote leap yr. If a yr ends in 00 and its hundreds are in bold it is a leap yr. Thus 19 indicates that 1900 is not a Gregorian jump year, (but xix in the Julian column indicates that it is a Julian leap year, as are all Julian x00 years). xx indicates that 2000 is a leap yr. Utilise January and Feb only in leap years.

Hundreds of Years Remaining Year Digits Month D
o
W
#
Julian
(r ÷ 7)
Gregorian
(r ÷ 4)
r5 nineteen 16 twenty r0 00 06   17 23 28 34   45 51 56 62   73 79 84 xc Jan Oct Sa 0
r4 18 15 xix r3 01 07 12 18 29 35 xl 46 57 63 68 74 85 91 96 May Su i
r3 17
N/A
02   xiii xix 24 30   41 47 52 58   69 75 80 86   97 Feb Aug One thousand two
r2 xvi 18 22 r2 03 08 14   25 31 36 42   53 59 64 70   81 87 92 98 Feb Mar Nov Tu three
r1 15
North/A
  09 fifteen 20 26   37 43 48 54   65 71 76 82   93 99 Jun West 4
r0 14 17 21 r1 04 10   21 27 32 38   49 55 lx 66   77 83 88 94 Sep Dec Th five
r6 13
N/A
05 11 16 22 33 39 44 fifty 61 67 72 78 89 95 Jan Apr Jul F 6

For determination of the day of the week (1 January 2000, Saturday)

  • the day of the month: 1 ~ 31 (1)
  • the month: (half dozen)
  • the yr: (0)
  • the century mod iv for the Gregorian agenda and mod 7 for the Julian calendar (0).
  • adding 1+6+0+0=7. Dividing by 7 leaves a residue of 0, so the day of the week is Saturday.

The formula is w = (d + yard + y + c) mod 7.

Revised Julian calendar [edit]

Note that the appointment (and hence the day of the week) in the Revised Julian and Gregorian calendars is the aforementioned from fourteen October 1923 to 28 February AD 2800 inclusive and that for large years it may be possible to decrease 6300 or a multiple thereof earlier starting so equally to reach a year which is within or closer to the table.

To look up the weekday of any date for any year using the table, decrease 100 from the year, dissever the deviation by 100, multiply the resulting quotient (omitting fractions) by vii and split up the product by nine. Note the quotient (omitting fractions). Enter the table with the Julian yr, and just before the terminal partition add 50 and subtract the caliber noted in a higher place.

Example: What is the twenty-four hour period of the week of 27 January 8315?

8315−6300=2015, 2015−100=1915, 1915/100=19 remainder 15, xix×7=133, 133/nine=14 remainder vii. 2015 is 700 years ahead of 1315, then 1315 is used. From table: for hundreds (xiii): vi. For remaining digits (15): 4. For month (January): 0. For date (27): 27. half-dozen + 4 + 0 + 27 + 50 − 14 = 73. 73/7=10 balance three. 24-hour interval of week = Tuesday.

Dominical Letter [edit]

To observe the Dominical Letter, calculate the day of the week for either 1 January or 1 October. If it is Sunday, the Dominical Letter is A, if Saturday B, and similarly backwards through the week and forwards through the alphabet to Mon, which is G.

Bound years have two Sunday Letters, and then for Jan and February calculate the 24-hour interval of the week for i January and for March to Dec calculate the day of the week for 1 October.

Leap years are all years which divide exactly by four with the following exceptions:

In the Gregorian calendar - all years which split exactly by 100 (other than those which carve up exactly by 400).

In the Revised Julian calendar - all years which divide exactly past 100 (other than those which give remainder 200 or 600 when divided by 900).

The "doomsday" [edit]

This is an artefact of recreational mathematics. Run into doomsday rule for an explanation.

Check the effect [edit]

Apply this table for finding the day of the week without any calculations.

Index Mon
A
Tue
B
Wed
C
Thu
D
Fri
Eastward
Saturday
F
Sunday
G
Perpetual Gregorian and Julian calendar
Use Jan and February for jump years
Engagement letter in twelvemonth row for the letter of the alphabet in century row

All the C days are doomsdays

Julian
century
Gregorian
century
Date 01
08
xv
22
29
02
09
16
23
30
03
x
17
24
31
04
11
18
25
05
12
nineteen
26
06
xiii
20
27
07
14
21
28
12 19 xvi twenty Apr Jul Jan Grand A B C D Due east F 01 07 12 eighteen 29 35 xl 46 57 63 68 74 85 91 96
13 20 Sep Dec F One thousand A B C D E 02 xiii 19 24 xxx 41 47 52 58 69 75 80 86 97
14 21 17 21 Jun Eastward F G A B C D 03 08 xiv 25 31 36 42 53 59 64 70 81 87 92 98
15 22 Feb Mar Nov D E F G A B C 09 15 20 26 37 43 48 54 65 71 76 82 93 99
16 23 xviii 22 Aug Feb C D E F K A B 04 x 21 27 32 38 49 55 sixty 66 77 83 88 94
17 24 May B C D E F G A 05 eleven 16 22 33 39 44 50 61 67 72 78 89 95
xviii 25 19 23 Jan October A B C D E F 1000 06 17 23 28 34 45 51 56 62 73 79 84 xc 00
[Year/100] Gregorian
century
20
16
21
17
22
xviii
23
19
Year mod 100
Julian
century
xix
12
20
13
21
fourteen
22
xv
23
16
24
17
25
18

Examples:

  • For mutual method
26 Dec 1893 (GD)

December is in row F and 26 is in column E, so the alphabetic character for the appointment is C located in row F and column Due east. 93 (year modernistic 100) is in row D (year row) and the letter C in the year row is located in column Grand. eighteen ([year/100] in the Gregorian century cavalcade) is in row C (century row) and the letter in the century row and cavalcade G is B, so the 24-hour interval of the week is Tuesday.

thirteen Oct 1307 (JD)

October thirteen is a F day. The letter F in the year row (07) is located in column G. The letter in the century row (13) and column Yard is E, and so the mean solar day of the week is Friday.

1 January 2000 (GD)

Jan 1 corresponds to Grand, G in the year row (00) corresponds to F in the century row (20), and F corresponds to Saturday.

A pithy formula for the method: "Appointment letter (Grand), letter of the alphabet (G) is in yr row (00) for the letter of the alphabet (F) in century row (20), and for the solar day, the letter (F) get weekday (Sat)".

The Sunday Letter method

Each day of the year (other than 29 February) has a letter allocated to it in the recurring sequence ABCDEFG. The series begins with A on 1 Jan and continues to A again on 31 December. The Dominicus letter of the alphabet is the 1 which stands against all the Sundays in the year. Since 29 February has no alphabetic character, this ways that the Sunday Letter for March to December is one stride dorsum in the sequence compared to that for Jan and February. The letter of the alphabet for any date volition be found where the row containing the month (in black) at the left of the "Latin square" meets the column containing the date above the "Latin square". The Sunday letter will exist found where the column containing the century (below the "Latin square") meets the row containing the yr's last two digits to the right of the "Latin square". For a leap yr, the Lord's day letter thus found is the i which applies to March to December.

So, for instance, to find the weekday of 16 June 2020:

Column "xx" meets row "20" at "D". Row "June" meets column "16" at "F". As F is two letters on from D, so the weekday is two days on from Sunday, i.e. Tuesday.

Mathematical algorithms [edit]

Rata Die [edit]

The niggling Rata Die method works by calculation up the number of days d that has passed since a date of known twenty-four hour period of the week D. The mean solar day of-the-week is and then given by (D + d) mod vii, conforming to whatever convention was used to encode D.

This method is more expensive than needed, and is not practical for human calculation. IBM has used a Rata Die method in its REXX programming linguistic communication, using the known base of operations date of one January, Advertizement one, a Mon.[5]

For example, the date of 13 August 2009 is 733632 days from January AD 1. Dividing the number by 7 yields 4, hence a Thursday.

Gauss's algorithm [edit]

Carl Friedrich Gauss described a method for computing the twenty-four hours of the week for one January in whatever given year in a handwritten notation in a collection of astronomical tables.[6] He never published it. It was finally included in his collected works in 1927.[vii] Compared to Rata Die, the consequence helps simplify the counting of years.

Gauss' method was applicable to the Gregorian calendar. He numbered the weekdays from 0 to half dozen starting with Sunday. He defined the post-obit functioning.

Inputs
Year number A, calendar month number One thousand, solar day number D.
Output
Day of year.
Procedure
  1. Get-go make up one's mind the solar day-of-week d 1 of one January.
    • For a Gregorian agenda, the weekday is ( 1 + 5 ( ( A ane ) % 4 ) + 4 ( ( A 1 ) % 100 ) + 6 ( ( A 1 ) % 400 ) ) % 7 {\displaystyle (1+5((A-1)\%4)+4((A-1)\%100)+half dozen((A-ane)\%400))\%7} .[6] Alternatively, set C = A \ 100, Y = A % 100, and the value is ( ane + 5 ( ( Y 1 ) % 4 ) + iii ( Y 1 ) + 5 ( C % 4 ) ) % 7 {\displaystyle (1+5((Y-1)\%4)+three(Y-ane)+5(C\%iv))\%7} .
    • For a Julian calendar, the weekday is R ( half-dozen + 5 R ( A 1 , 4 ) + three ( A i ) , 7 ) {\displaystyle R(half-dozen+5R(A-1,4)+3(A-1),seven)} or R ( half dozen + 5 R ( Y 1 , iv ) + 3 ( Y 1 ) + half-dozen C , 7 ) {\displaystyle R(6+5R(Y-i,iv)+3(Y-1)+6C,7)} .
  2. Now determine the month-related first m by using the lookup table with 1000.
  3. Return d = (d one + thou + D) % 7.
Tabular array of month offsets
Months January February Mar April May Jun Jul Aug Sep Oct Nov Dec
Mutual years 0 3 3 6 i 4 6 2 five 0 3 5
Jump years 4 0 ii 5 0 3 6 ane iv 6

The above procedure can be condensed into a unmarried expression for the Gregorian case:

R ( D + m + v R ( A ane , 4 ) + 4 R ( A i , 100 ) + half-dozen R ( A 1 , 400 ) , vii ) {\displaystyle R(D+chiliad+5R(A-1,4)+4R(A-i,100)+6R(A-1,400),vii)}

Worked example [edit]

For twelvemonth number 2000, A − 1 = 1999, Y − one = 99 and C = nineteen, the weekday of 1 Jan is

= R ( 1 + 5 R ( 1999 , 4 ) + 4 R ( 1999 , 100 ) + vi R ( 1999 , 400 ) , 7 ) = R ( one + one + 4 + 0 , 7 ) = vi {\displaystyle {\brainstorm{aligned}&=R(ane+5R(1999,4)+4R(1999,100)+6R(1999,400),7)\\&=R(1+one+4+0,vii)\\&=6\end{aligned}}}
= R ( 1 + 5 R ( 99 , four ) + 3 × 99 + 5 R ( nineteen , 4 ) , 7 ) = R ( 1 + 1 + 3 + 1 , vii ) = 6 = Saturday . {\displaystyle {\brainstorm{aligned}&=R(1+5R(99,4)+3\times 99+5R(19,iv),7)\\&=R(1+1+iii+1,7)\\&=6={\text{Saturday}}.\finish{aligned}}}

The weekdays for xxx April 1777 and 23 February 1855 are

= R ( 30 + 6 + 5 R ( 1776 , four ) + four R ( 1776 , 100 ) + 6 R ( 1776 , 400 ) , 7 ) = R ( two + half-dozen + 0 + 3 + six , 7 ) = three = Wednesday {\displaystyle {\begin{aligned}&=R(30+6+5R(1776,iv)+4R(1776,100)+6R(1776,400),seven)\\&=R(2+half dozen+0+3+6,7)\\&=3={\text{Wednesday}}\end{aligned}}}

and

= R ( 6 + 23 + two.6 × 12 + five R ( 1854 , four ) + 4 R ( 1854 , 100 ) + 6 R ( 1854 , 400 ) , 7 ) = R ( half dozen + 2 + 4 + 3 + 6 + 5 , vii ) = 5 = Fri . {\displaystyle {\begin{aligned}&=R(six+23+\left\lceil two.half dozen\times 12\right\rceil +5R(1854,4)+4R(1854,100)+6R(1854,400),vii)\\&=R(half-dozen+two+4+three+6+5,vii)\\&=5={\text{Friday}}.\finish{aligned}}}

Explanation and notes [edit]

The algorithm for the day-of-week of 1 Jan tin be proven using modulo arithmetics. The chief point is that considering 365 modernistic 7 = one, each year adds 1 day to the progression. The residual is adjustment for spring year. The century-based versions take 36525 mod 7 = six.

The table of month offsets show a departure in February due to the leap yr. A common technique (later used by Zeller) is to shift the calendar month to offset with March, so that the leap 24-hour interval is at the tail of the counting. In addition, as after shown by Zeller, the table can be replaced with an arithmetic expression.

This formula was also converted into graphical and tabular methods for calculating any day of the week past Kraitchik and Schwerdtfeger.[seven] [8]

Disparate variation [edit]

The following formula is an example of a version without a lookup table and with a transposed calendar month. The formula is

w = ( d + 2.6 m 0.2 + y + y iv + c 4 2 c ) mod 7 , {\displaystyle w=\left(d+\lfloor 2.6m-0.2\rfloor +y+\left\lfloor {\frac {y}{4}}\right\rfloor +\left\lfloor {\frac {c}{four}}\correct\rfloor -2c\right){\bmod {7}},}

where

  • Y is the year minus 1 for January or February, and the year for whatsoever other calendar month
  • y is the last 2 digits of Y
  • c is the first 2 digits of Y
  • d is the solar day of the month (ane to 31)
  • 1000 is the shifted month (March=i,…,February=12)
  • westward is the mean solar day of calendar week (0=Sunday,…,6=Saturday). If w is negative you accept to add 7 to it.
Tabular array of month offsets ( ii.6 m 0.2 {\displaystyle \lfloor 2.6m-0.2\rfloor } )
Months Jan Feb Mar Apr May Jun July Aug Sep Oct Nov Dec
Offset 0 three 2 5 0 3 5 ane four vi 2 4

Zeller's algorithm [edit]

In Zeller'southward algorithm, the months are numbered from 3 for March to xiv for Feb. The yr is assumed to brainstorm in March; this means, for example, that January 1995 is to exist treated as month 13 of 1994.[9] The formula for the Gregorian calendar is

w ( thirteen ( 1000 + one ) 5 + y four + c 4 + d + y 2 c ) mod vii {\displaystyle due west\equiv \left(\left\lfloor {\frac {xiii(m+ane)}{v}}\right\rfloor +\left\lfloor {\frac {y}{4}}\right\rfloor +\left\lfloor {\frac {c}{four}}\correct\rfloor +d+y-2c\right){\bmod {7}}}

where

  • Y is the year minus 1 for January or Feb, and the twelvemonth for whatever other calendar month
  • y is the last ii digits of Y
  • c is the first ii digits of Y
  • d is the twenty-four hours of the month (1 to 31)
  • m is the shifted calendar month (March=iii,...January = thirteen, February=xiv)
  • w is the day of week (1=Sunday,..0=Sabbatum)

The only difference is one between Zeller's algorithm (Z) and the Disparate Gaussian algorithm (G), that is ZG = 1 = Sunday.

( d + ( 1000 + 1 ) 2.6 + y + y / 4 + c / 4 2 c ) mod seven ( d + 2.six m 0.2 + y + y / four + c / 4 2 c ) modernistic 7 {\displaystyle (d+\lfloor (m+1)ii.6\rfloor +y+\lfloor y/4\rfloor +\lfloor c/4\rfloor -2c){\bmod {7}}-(d+\lfloor two.6m-0.2\rfloor +y+\lfloor y/4\rfloor +\lfloor c/4\rfloor -2c){\bmod {seven}}}
= ( ( yard + 2 + 1 ) 2.half-dozen ( 2.six m 0.2 ) ) modern 7 {\displaystyle =(\lfloor (m+two+i)two.6-(2.6m-0.2)\rfloor ){\bmod {7}}} (March = iii in Z but March = i in G)
= ( 2.vi m + 7.8 ii.6 m + 0.2 ) mod seven {\displaystyle =(\lfloor 2.6m+vii.8-two.6m+0.two\rfloor ){\bmod {seven}}}
= 8 mod vii = ane {\displaystyle =viii{\bmod {vii}}=one}
Table of month offsets ( 2.half-dozen ( m + one ) {\displaystyle \lfloor 2.vi(yard+1)\rfloor } )
Months Mar Apr May Jun Jul Aug Sep Oct November Dec Jan February
Beginning 1 4 iii 6 1 4 6 two 5 0 iii five

Wang'southward algorithm [edit]

Wang'south algorithm[10] for human being calculation of the Gregorian calendar is (the formula should be subtracted by 1 if m is 1 or 2 if the year is a jump twelvemonth)

due west = ( d d 0 ( yard ) + y 0 y 1 + y 0 / 4 y i / 2 ii ( c mod four ) ) mod 7 , {\displaystyle west=\left(d-d_{0}(k)+y_{0}-y_{ane}+\left\lfloor y_{0}/4-y_{one}/2\correct\rfloor -ii\left(c{\bmod {iv}}\right)\right){\bmod {7}},}

where

thou d 0 ( one thousand ) {\displaystyle d_{0}(thousand)}
1 1 A day
3 5 m + 2
v 7
7 nine
ix 3 m + 1
11 12
2 12 k + three
iv 2 k − 2
six 4
8 6
ten eight
12 10

An algorithm for the Julian calendar can be derived from the algorithm above

westward = ( d d 0 ( m ) + y 0 y ane + y 0 / 4 y 1 / two c ) mod 7 , {\displaystyle w=\left(d-d_{0}(yard)+y_{0}-y_{1}+\left\lfloor y_{0}/4-y_{ane}/two\correct\rfloor -c\right){\bmod {7}},}

where d 0 ( m ) {\displaystyle d_{0}(chiliad)} is a doomsday.

thou d 0 ( one thousand ) {\displaystyle d_{0}(m)}
one three C day
3 7 chiliad + 4
5 9
7 11
nine v grand − 4
eleven vii
2 0 grand − 2
4 4 grand
6 6
8 8
10 10
12 12

Other algorithms [edit]

Schwerdtfeger's method [edit]

In a partly tabular method by Schwerdtfeger, the year is separate into the century and the two digit twelvemonth within the century. The arroyo depends on the month. For m ≥ 3,

c = y 100 and g = y 100 c , {\displaystyle c=\left\lfloor {\frac {y}{100}}\correct\rfloor \quad {\text{and}}\quad k=y-100c,}

then chiliad is between 0 and 99. For m = i,ii,

c = y i 100 and g = y one 100 c . {\displaystyle c=\left\lfloor {\frac {y-i}{100}}\right\rfloor \quad {\text{and}}\quad g=y-1-100c.}

The formula for the day of the calendar week is[7]

westward = ( d + e + f + g + one thousand 4 ) mod vii , {\displaystyle due west=\left(d+e+f+g+\left\lfloor {\frac {yard}{4}}\right\rfloor \correct){\bmod {7}},}

where the positive modulus is called.[seven]

The value of e is obtained from the following table:

1000 1 two iii 4 5 half-dozen 7 8 9 ten xi 12
due east 0 3 ii 5 0 3 5 i 4 6 2 iv

The value of f is obtained from the following table, which depends on the agenda. For the Gregorian agenda,[7]

c mod 4 0 ane 2 3
f 0 v three i

For the Julian agenda,[seven]

c mod 7 0 ane two 3 four 5 6
f 5 4 iii 2 1 0 6

Lewis Carroll's method [edit]

Charles Lutwidge Dodgson (Lewis Carroll) devised a method resembling a puzzle, yet partly tabular in using the same index numbers for the months as in the "Complete table: Julian and Gregorian calendars" above. He lists the same three adjustments for the first 3 months of non-spring years, 1 seven higher for the last, and gives cryptic instructions for finding the rest; his adjustments for centuries are to be determined using formulas similar to those for the centuries tabular array. Although explicit in asserting that his method too works for Onetime Manner dates, his example reproduced beneath to decide that "1676, February 23" is a Wednesday only works on a Julian calendar which starts the twelvemonth on Jan one, instead of March 25 every bit on the "Onetime Style" Julian calendar.

Algorithm: [11]

Have the given date in 4 portions, viz. the number of centuries, the number of years over, the month, the day of the month.

Compute the post-obit 4 items, adding each, when found, to the total of the previous items. When an particular or full exceeds 7, divide by vii, and go on the remainder just.

Century-item: For 'Old Fashion' (which ended 2 September 1752) subtract from 18. For 'New Way' (which began 14 September 1752) divide by 4, take overplus [surplus] from 3, multiply remainder by 2.

Year-item: Add together the number of dozens, the overplus, and the number of 4s in the overplus.

Calendar month-item: If it begins or ends with a vowel, decrease the number, denoting its identify in the twelvemonth, from 10. This, plus its number of days, gives the item for the following month. The item for January is "0"; for February or March, "3"; for December, "12".

Day-item: The total, thus reached, must exist corrected, by deducting "i" (first adding seven, if the total be "0"), if the engagement be January or February in a jump year, remembering that every year, divisible by four, is a Leap Yr, excepting only the century-years, in `New Style', when the number of centuries is non so divisible (east.g. 1800).

The last outcome gives the twenty-four hour period of the week, "0" meaning Sunday, "ane" Mon, and then on.

Examples: [eleven]

1783, September 18

17, divided by 4, leaves "1" over; one from 3 gives "2"; twice 2 is "iv". 83 is half-dozen dozen and 11, giving 17; plus ii gives 19, i.e. (dividing by 7) "5". Total ix, i.east. "2" The item for August is "8 from 10", i.e. "2"; then, for September, it is "two plus 31", i.e. "5" Total 7, i.e. "0", which goes out. 18 gives "iv". Respond, "Thursday".

1676, February 23

16 from 18 gives "two" 76 is 6 dozen and 4, giving 10; plus 1 gives 11, i.e. "four". Total "half dozen" The item for February is "3". Full 9, i.e. "2" 23 gives "2". Full "4" Correction for Jump Twelvemonth gives "3". Answer, "Wednesday".

Since 23 February 1676 (counting February as the second month) is, for Carroll, the same day as Gregorian four March 1676, he fails to arrive at the correct answer, namely "Fri," for an Old Style date that on the Gregorian agenda is the aforementioned solar day as 5 March 1677. Had he correctly assumed the year to begin on the 25th of March, his method would have accounted for differing year numbers - merely like George Washington'southward birthday differs - between the two calendars.

It is noteworthy that those who have republished Carroll'southward method have failed to point out his fault, near notably Martin Gardner.[12]

In 1752, the British Empire abandoned its use of the Former Mode Julian calendar upon adopting the Gregorian calendar, which has become today's standard in virtually countries of the globe. For more background, run into Old Manner and New Mode dates.

Methods in computer code [edit]

Keith [edit]

In the C language expressions beneath, y, m and d are, respectively, integer variables representing the year (e.g., 1988), calendar month (1-12) and day of the month (1-31).

                        (            d            +=            k            <            iii            ?            y            --:            y            -2            ,            23            *            yard            /            9            +            d            +            4            +            y            /            4            -            y            /            100            +            y            /            400            )            %            seven                      

In 1990, Michael Keith and Tom Craver published the foregoing expression that seeks to minimize the number of keystrokes needed to enter a self-contained function for converting a Gregorian date into a numerical day of the week.[13] It returns 0 = Sunday, 1 = Monday, etc. This expression uses a less cumbersome month component than does Zeller'southward algorithm.

Before long afterwards, Hans Lachman streamlined their algorithm for ease of use on low-finish devices. Equally designed originally for four-function calculators, his method needs fewer keypad entries by limiting its range either to A.D. 1905–2099, or to historical Julian dates. It was later modified to catechumen any Gregorian date, fifty-fifty on an abacus. On Motorola 68000-based devices, there is similarly less demand of either processor registers or opcodes, depending on the intended pattern objective.[fourteen]

Sakamoto's methods [edit]

The tabular forerunner to Tøndering's algorithm is embodied in the post-obit K&R C function.[fifteen] With minor changes, it was adapted for other high level programming languages such as APL2.[sixteen] Posted by Tomohiko Sakamoto on the comp.lang.c Usenet newsgroup in 1992, it is accurate for whatsoever Gregorian date.[17] [18]

                        dayofweek            (            y            ,                                    grand            ,                                    d            )                                    /* 1 <= thousand <= 12,  y > 1752 (in the U.M.) */                        {                                                static                                    int                                    t            []                                    =                                    {            0            ,                                    3            ,                                    ii            ,                                    5            ,                                    0            ,                                    3            ,                                    5            ,                                    1            ,                                    four            ,                                    6            ,                                    ii            ,                                    4            };                                                if                                    (                                    m                                    <                                    three                                    )                                                {                                                y                                    -=                                    one            ;                                                }                                                render                                    (            y                                    +                                    y            /            four                                    -                                    y            /            100                                    +                                    y            /            400                                    +                                    t            [            m            -1            ]                                    +                                    d            )                                    %                                    7            ;                        }                      

It returns 0 = Sun, 1 = Monday, etc.

Sakamoto as well simultaneously posted a more obfuscated version:

                        dow            (            grand            ,            d            ,            y            )                                    {                                    y            -=            m            <            3            ;                                    render            (            y            +            y            /            4            -            y            /            100            +            y            /            400            +            "-bed=pen+mad."            [            m            ]            +            d            )            %            7            ;                                    }                      

This version encodes the calendar month offsets in the string and as a issue requires a reckoner that uses standard ASCII to run the algorithm correctly, reducing its portability. In improver, both algorithms omit int type declarations, which is allowed in the original M&R C simply not immune in ANSI C.

(Tøndering's algorithm is, once again, similar in structure to Zeller'southward congruence and Keith's short code, except that the calendar month-related component is 31*m/12. Sakamoto's is somewhere between the Disparate Gaussian and the Schwerdtfeger'southward algorithm, evidently unaware of the expression form.)

See as well [edit]

  • Doomsday dominion
  • Julian 24-hour interval
  • Mental Calculation Earth Loving cup (Has a agenda calculation contest)
  • Perpetual agenda
  • Buddhist calendar

References [edit]

Notes [edit]

  1. ^ To explain this in detail, visualise a calendar hanging on the wall depicting a calendar month beginning on Lord's day (eastward.k. March 2020). You volition encounter that the 1st is a Sunday. At present count forwards vii days. This brings you to the 8th, which is also a Sunday. Count forward 10 days. This brings you to the 18th, which is a Wednesday. Now the 4th is a Midweek (being three days afterwards Sunday 1st). Count forward seven days. This brings you to Wed 11th, three days after Sunday 8th. Count forward another seven days. This brings y'all to Wednesday 18th, 3 days subsequently Lord's day 15th, which falls 2 weeks after Sunday 1st.
  2. ^ The numbers in the showtime column are proleptic - the Gregorian calendar was non devised till 1582. See the annotation beneath the table.
  3. ^ The Julian century start 1 BC would as well announced on this line of the tabular array (to the left of 700) but there is no space to include it.

Citations [edit]

  1. ^ a b Brothers, Hardin; Rawson, Tom; Conn, Rex C.; Paul, Matthias R.; Dye, Charles Eastward.; Georgiev, Luchezar I. (2002-02-27). 4DOS 8.00 online help.
  2. ^ "HP Prime - Portal: Firmware update" (in High german). Moravia Instruction. 2015-05-fifteen. Archived from the original on 2016-eleven-05. Retrieved 2015-08-28 .
  3. ^ Paul, Matthias R. (1997-07-30). NWDOS-TIPs — Tips & Tricks rund um Novell DOS vii, mit Blick auf undokumentierte Details, Bugs und Workarounds. MPDOSTIP. Release 157 (in German) (3rd ed.). Archived from the original on 2016-11-04. Retrieved 2014-08-06 . (NB. NWDOSTIP.TXT is a comprehensive work on Novell DOS seven and OpenDOS 7.01, including the description of many undocumented features and internals. It is role of the writer's yet larger MPDOSTIP.Zilch drove maintained upwardly to 2001 and distributed on many sites at the time. The provided link points to a HTML-converted older version of the NWDOSTIP.TXT file.)
  4. ^ Richards, E. G. (1999). Mapping Time: The Calendar and Its History . Oxford University Press.
  5. ^ REXX/400 Reference transmission page 87 (1997).
  6. ^ a b Gauss, Carl F. (1981). "Den Wochentag des i. Januar eines Jahres zu finden. Gueldene Zahl. Epakte. Ostergrenze.". Werke. herausgegeben von der Koeniglichen Gesellschaft der Wissenschaften zu Goettingen (2nd ed.). Hildesheim: Georg Olms Verlag. pp. 206–207. ISBN978-3-48704643-3.
  7. ^ a b c d due east f Schwerdtfeger, Berndt Due east. (2010-05-07). "Gauss' calendar formula for the solar day of the calendar week" (PDF) (1.4.26 ed.). Retrieved 2012-12-23 .
  8. ^ Kraitchik, Maurice (1942). "Affiliate 5: The agenda". Mathematical recreations (2nd revised [Dover] ed.). Mineola: Dover Publications. pp. 109–116. ISBN978-0-48645358-3.
  9. ^ Stockton, J. R. (2010-03-19). "The Calendrical Works of Rektor Chr. Zeller: The Twenty-four hours-of-Week and Easter Formulae". Merlyn . Retrieved 2012-12-nineteen .
  10. ^ Wang, Xiang-Sheng (March 2015). "Calculating the day of the week: naught-days algorithm" (PDF). Recreational Mathematics Magazine. No. 3. p. 5.
  11. ^ a b Dodgson, C.Fifty. (Lewis Carroll). (1887). "To find the solar day of the week for any given date". Nature, 31 March 1887. Reprinted in Mapping Fourth dimension, pp. 299-301.
  12. ^ Martin Gardner. (1996). The Universe in a Handkerchief: Lewis Carroll's Mathematical Recreations, Games, Puzzles, and Word Plays, pages 24-26. Springer-Verlag.
  13. ^ Michael Keith; Tom Craver. (1990). The ultimate perpetual calendar? Journal of Recreational Mathematics, 22:4, pp.280-282.
  14. ^ The 4-function Reckoner; The Assembly of Motorola 68000 Orphans; The Abacus. gopher://sdf.org/1/users/retroburrowers/TemporalRetrology
  15. ^ "Day-of-week algorithm NEEDED!" news:1993Apr20.075917.16920@sm.sony.co.jp
  16. ^ APL2 IDIOMS workspace: Appointment and Time Algorithms, line 15. ftp://ftp.software.ibm.com/ps/products/apl2/info/APL2IDIOMS.pdf (2002)
  17. ^ "Date -> Day of calendar week conversion". Google newsgroups:comp.lang.c. Dec 1992. Retrieved 2020-06-21 .
  18. ^ "DOW algorithm". Google newsgroups:comp.lang.c. 1994. Retrieved 2020-06-21 .

Further reading [edit]

  • Hale-Evans, Ron (2006). "Hack #43: Calculate any weekday". Mind performance hacks (1st ed.). Beijing: O'Reilly. pp. 164–169. ISBN9780596101534.
  • Thioux, Marc; Stark, David E.; Klaiman, Cheryl; Schultz, Robert T. (2006). "The day of the week when y'all were born in 700 ms: Calendar ciphering in an autistic savant". Periodical of Experimental Psychology: Human Perception and Operation. 32 (five): 1155–1168. doi:ten.1037/0096-1523.32.v.1155.
  • Treffert, Darold A. "Why agenda calculating?". Islands of genius : the bountiful mind of the autistic, caused, and sudden savant (1. publ., [repr.]. ed.). London: Jessica Kingsley. pp. 63–66. ISBN9781849058735.

External links [edit]

  • Tøndering's algorithm for both Gregorian and Julian calendars
  • "Key Twenty-four hours" method used so equally to reduce computation & memorization
  • Compact tabular method for memorisation, also for the Julian agenda
  • When countries changed from the Julian agenda
  • World records for mentally calculating the day of the week in the Gregorian Calendar
  • National records for finding Calendar Dates
  • World Ranking of Memoriad Mental Calendar Dates (all competitions combined)
  • Identify the year by given month, day, day of calendar week.

yoshiokafromming.blogspot.com

Source: https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week

Post a Comment for "When Do Dates Fall on the Same Weekday Again"