The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

Days between dates calculation
Message #1 Posted by Hunter on 3 Mar 2004, 1:42 p.m.

I'm writing code for my 41CV to replicate the DATE function in the 12C (the code that came with the 41CV for calendar math isn't as rigorous as that used by later calculators).

The 12C manual shows the formula used to convert dd.mmyyyy inputs into absolute days. So once you input, say, March 3 2004 into the y register, and 10 as the number of incremental days, you can calc what the new absolute day figure is for 10 days after March 3, 2004. But converting this back to 3,13,2004 is a bit of a puzzle.

Furthermore, it appears to me that the formulas used even by the later calculators isn't exactly right: Years evenly divisible by 400 are leap years, but years evenly divisible by 100 aren't; of course, years evenly divisible by 4 are. The formula HP uses on the 12C, 19BII, etc. doesn't take this into account, so when it calculates the number of days between 31 Dec 1899 and today, it'll be off by 1 day.

      
Re: Days between dates calculation
Message #2 Posted by Erik Ehrling (Sweden) on 3 Mar 2004, 2:07 p.m.,
in response to message #1 by Hunter

Hi! There is a set of programs by Christoph Giesselink that does exactly this for the HP-42S on my homepage and that works on every year between 1583 and 9999.

Should be very easy to adapt these programs for the HP-41C series.

Best regards,
Erik Ehrling (Sweden)
Homepage:http://www.hp42s.com

      
Re: Days between dates calculation using Julian Day Numbers
Message #3 Posted by Trent Moseley on 3 Mar 2004, 2:32 p.m.,
in response to message #1 by Hunter

The Sky & Telescope website has BASIC programs which are easily converted to RPN. They use the Julian Day Number which begins at noon on January 1, 4713 B.C. You can convert dates to the JDN and visa-versa. Find the difference between two day numbers and you have the number of days in between.

tm

            
Re: Days between dates calculation using Julian Day Numbers
Message #4 Posted by Chan Tran on 3 Mar 2004, 3:38 p.m.,
in response to message #3 by Trent Moseley

I found that the time module (or a 41CX) DDays function is accurate. So may be you can just get a time module?


[ Return to Index | Top of Index ]

Go back to the main exhibit hall