Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!kth.se!cyklop.nada.kth.se!news From: d90-awe@dront.nada.kth.se (Assar Westerlund) Newsgroups: comp.lang.pascal Subject: Re: weeknumber Summary: Weeknumber Message-ID: <1991Apr1.005702.17789@nada.kth.se> Date: 1 Apr 91 00:57:02 GMT References: <1991Mar24.195537.9726@cs.umu.se> <1991Mar30.075928.8077@cs.mcgill.ca> Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 32 In article <1991Mar24.195537.9726@cs.umu.se> dvllhd@cs.umu.se (Lars H{gglund) writes: >I'm looking for an algoritm or code to get the weeknumber from a date. >ex: 1990-12-31 ==> 1 Use Zeller's Congruence: q + ((m + 1) / 10) + K + K / 4 + J / 4 - 2 * J. Where q = Day of the month m = Month, but January and february are month #13 and #14 of prev year j = Century k = Year Take the result MOD 7 and you'll have the day of the week. Observe that it's MOD and not remainder what is what Turbo Pascal's operator MOD implements. For details, see DDJ Oct and Nov 1990. ################################################################################ Assar Westerlund Address: d90-awe@nada.kth.se ################################################################################