Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!ucsd!telesoft!mclow From: mclow@telesoft.telesoft.com (Marshall Clow @telesoft) Newsgroups: comp.sys.mac Subject: Re: Week DAYS (was Re: why 1904? ms excel) Summary: Neat Trick Message-ID: <488@telesoft.telesoft.com> Date: 9 Sep 89 07:11:58 GMT References: <457a7553.1285f@maize.engin.umich.edu> <972@mrsvr.UUCP> Organization: TeleSoft, San Diego, CA. Lines: 14 In article <972@mrsvr.UUCP>, hallett@shoreland.uucp (Jeff Hallett x4-6328) writes: > Interesting. One thing I've always wondered about, though, is, given > a date in the Gregorian calendar, how does one determine the day of > the week? There is obviously a brute force approach, but does someone > know (and will relate) an elegant solution? A trick I used in writing some routines was to notice that in any 400 year period there are 97 leap years and 303 non-leap years for a total of 146097 days, which is divisible by 7! This means that Jan 01, 1 is the same day of the week as Jan 01, 2001. ( Tuesday, if I remember ). From there, you can grunt the answer out. Marshall Clow mclow@telesoft.com