Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!cernvax!chx400!chx400!ugun2b!ugsc2a!fisher From: fisher@sc2a.unige.ch Newsgroups: comp.misc Subject: Re: Julian day numbers Message-ID: <1991Apr25.103747.406@sc2a.unige.ch> Date: 25 Apr 91 08:37:47 GMT References: <41601@cup.portal.com> Organization: University of Geneva, Switzerland Lines: 57 In article <41601@cup.portal.com>, J_Otto_Tennant@cup.portal.com writes: > In the introductory chapter of _Numerical_Recipies_, programs are > presented for the calculation of the Julian day number given a > date in the form of month/day/year, and vice-versa. > > The key trick, as described in a recent article in "Dr. Dobb's", > is to renumber months so that February is last. Given that wonderful > hack (which numbers March as "4" and February as "15"), the next step > is given as: > > JULDAY = INT(365.25*JY)+INT(30.6001*JM)+ID+1720995 > > [...] > > From my point of view, there are two aspects to the incomprehensibility > of 30.6001. > > [...] It's easily understood: as the "year" starts with March you want to add nothing for March, 31 days for April, 31+30 days for May, etc. Taking the INT( (NUM(Month)-NUM(March))*30.5 + 0.5) gives you alternating months of 31 and 30 days. But every five months, you need to add an extra day, and substract 0.5 from the original offset of 0.5. This means you add a half day every five month, or 0.1 every month. This is why you take 30.6 instead of 30.5. Now depending on the hardware (in some cases the software), the result of 30.6 * 5 is 153.0 or 152.99999... Small difference, but the resulting INT() changes. That is the reason for the 30.6001 (INT(JM*30.6+0.001) would work also, of course). Month NUM(Month) NUM*30.6001 Prev. months Last month Mar. 4 122.4004 0 (28/29) Apr. 5 153.0005 * 31 31 May 6 183.6006 61 30 Jun. 7 214.2007 92 31 Jul. 8 244.8008 122 30 Aug. 9 275.4009 153 31 Sep. 10 306.0010 * 184 31 Oct. 11 336.6011 214 30 Nov. 12 367.2012 245 31 Dec. 13 397.8013 275 30 Jan. 14 428.4014 306 31 Feb. 15 459.0015 * 337 31 The needed column is the total of days in the previous months, given by INT(NUM(Month)*30.6001) - 122. Of course, the 122 is included in the constant 1720995 in the example. NOTE: the example works only from 1. March 1990 to 28. Feb. 2100... Regards, Markus Fischer, Dept of Anthropology, Geneva CH