Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!adm!xadmx!RDK%vm.temple.edu@cunyvm.cuny.edu From: RDK%vm.temple.edu@cunyvm.cuny.edu (Robert Keiser) Newsgroups: comp.lang.pascal Subject: Re: Day-of-week algorithm, please! Message-ID: <19065@adm.BRL.MIL> Date: 10 Apr 89 18:35:30 GMT Sender: news@adm.BRL.MIL Lines: 28 I have used the following algorithm to get the Day of week. It will work for any date after 1800. In the following, Year is a 4 digit integer i.e. 1989 not just the 89 part. (* N = 1461*f(year,month) / 4 + 153*g(month) / 5 + day *) (* *) (* where: *) (* f(year,month) = year - 1 if month <= 2 *) (* year otherwise *) (* *) (* g(month) = month + 13 if month <= 2 *) (* month + 1 otherwise *) (* *) (* Then apply the following formula to N *) (* dow = (N - 621,049) MOD 7 *) (* *) (* This formula was found in _Programming in ANSI C_ *) (* by Stephen G. Kochan pg. 188 *) Robert Keiser Systems Analyst Temple University Computer Activities Bitnet : RDK@Templevm Internet : RDK@vm.temple.edu US Mail : Temple University Philadelphia, PA 19122