Zeller's Congruence |
Zeller's congruence is an algorithm devised by Christian Zeller to calculate the day of the week for any Julian or Gregorian calendar date. Calculating the day of the week for a particular date has always been a challenge for computer programmers. In the run up to Year 2000, dates became very important. Gloom and doom was predicted by many. The world was going to come to a screeching halt (if the press was to be believed). Fortunately a lot of IT people put in a lot of hours to ensure that it was a big non-event. As a part of that work many companies took the opportunity to implement standard solutions to address this issue. Many wrote their own data routines. Ours used Zeller's congruence to return the day of the week. So what is Zeller's congruence? The calculations for Zeller's congruence arw fairly complex but remarkably accurate. For Gregorian dates it is: Day Number = (dd + Int(13(mm+1))/5 + yyyy + Int(yyyy/4) - Int(yyyy/100) + Int(yyyy/400)) Mod 7 Day Number = (dd + Int(13(mm+1))/5 + yyyy + Int(yyyy/4) + 5) Mod 7 The calculated Day Number denotes the day of the week. i.e. 0 = Saturday Lets work a Gregorian example: What day of the week was 23rd April 1911? (23/4/1911) Day Number = (23 [Day] + Int((4 [Month]+1)13/5) + 1911 [Year]+ Int(1911[Year]/4) - Int(6(1911[Year]/100)) + Int(1911[Year]/400)) Mod 7 Day Number = (23 + 13 + 1911 + 477 - 114 + 4) Mod 7 Day Number = (2542) Mod 7 Day Number = 1 which means that 23rd April 1911 was a Sunday. Now it is important to remember that all dates prior to 24th March 1752 are required to use the calculation for Julian based dates In accordance with a 1750 act of Parliament, England and its colonies changed calendars in 1752. By that time, the discrepancy between a solar year and the Julian Calendar had grown by an additional day, so that the calendar used in England and its colonies was 11 days out-of-sync with the Gregorian Calendar in use in most other parts of Europe. Now lets work a Julian example: What day of the week was 13th October 1307? (13/10/1307). This was the day in history when the Knight's Templar were arrested. Day Number = (13 [Day] + Int((10 [Month]+1)13/5) + 1307 [Year]+ Int(1307[Year]/4) + 5) Mod 7 Day Number = (13 + 28 + 1307 + 326 + 5) Mod 7 Day Number = (1679) Mod 7 Day Number = 6 which means that 13th October 1307 was a Friday. It is believed that this is why people consider Friday 13th as a cursed or unlucky day. For a working example of this code written in Rexx please click here For a working example of this code written in VBA please click here |
||
Number of unique visitors 1003
Copyright © Abbydale Systems LLC 2015-2024
Abbydale Systems LLC Lic. 802696149. All rights reserved.