Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!portal!cup.portal.com!ts From: ts@cup.portal.com (Tim W Smith) Newsgroups: comp.sys.mac Subject: Re: Week DAYS (was Re: why 1904? ms excel) Message-ID: <22033@cup.portal.com> Date: 10 Sep 89 11:02:29 GMT References: <457a7553.1285f@maize.engin.umich.edu> <8909061947.AA00416@vs04csc.UMD.EDU> <972@mrsvr.UUCP> <28974@news.Think.COM> Organization: The Portal System (TM) Lines: 47 The formula is not too hard to work out. If you want to, however, you will find it much easier if you pretend that March 1 is the start of the year. If you want to find day-of-week from a given date in this century, there is a simple method Martin Gardner gave once that is easy to do in your head. You need to memorize the following 12 numbers: 1 4 4 0 2 5 0 3 6 1 4 6 Let's say you want the day of the week for M/D/19YY. You first divide YY by 12, given, say, A with a remainder of B. Divide B by 4. Add these numbers together. In other words, YY/12 + YY%12 + (YY%12)/4 Let's call this N. Now use the month, M, to look up a number in that table given above. Add this to N. Then add D. Reduce this mod 7. This gives you the day of the week, with 0 == Saturday, etc. For example, today is 9/10/1989. 89/12 = 7 89%12 = 5 5/4 = 1 ---------- N = 13, which we can reduce mod 7 to 6. You might as well remember this number, since it will be valid all year. Number for September ( 9th number in 1 4 4 0 2 5 0 3 6 1 4 6 ) is 6. Thus, today is 6 + 6 + 10 = 22. Mod 7, this is 1, or Sunday. Hey, it worked! Another example, 12/7/1941. 41/12 = 3, 41%12 = 5, 5/4 = 1. Number for December = 6. Day of week is 9+6+7 = 1 mod 7 which is Sunday. If the year is a leap year, modify the month table as follows for that year: 0 3 4 0 2 5 0 3 6 1 4 6 Tim Smith