Deltadays and date functions.
|
05-10-2017, 05:01 PM
(This post was last modified: 05-10-2017 09:17 PM by Dieter.)
Post: #8
|
|||
|
|||
RE: Deltadays and date functions.
(05-10-2017 01:28 PM)Vtile Wrote: I have been in seach of simple algorithm to calculate dDays between two dates. What? Heavy? A program that works correctly for any valid Gregorian date can be done in less than 80 steps. Take a look at the old HP41 library on this website. (05-10-2017 01:28 PM)Vtile Wrote: ...as it needs to be accurate only between about 100 year time window. In this case things can be simplified a bit. For dates between (and including) 1 Mar 1900 and 28 Feb 2100 every fourth year is a leap year (that's because 2000 is one). This allows to use a simpler formula. (05-10-2017 01:28 PM)Vtile Wrote: I did found one that suits my use at: https://groups.google.com/forum/#!topic/...c9rcvY7d2s Hmmm... looks like a few things have been mixed up there. See below. (05-10-2017 01:28 PM)Vtile Wrote: Now interesting enough I did put 3 different methods to the excel worksheet to compare them simultaneusly.. If I take DDays from 28.2.1900 and 28.2.2100 I get results: 73049 is correct. As usual, Excel cannot be trusted under all circumstances. The date functions only work for a certain range, so you better write your own. (05-10-2017 01:28 PM)Vtile Wrote: ** From mailinglist discussion As already mentioned, some things get mixed up here. For instance an Y and M adjustment has to be applied only for Jan and Feb, and not for all months. For dates between 1 Mar 1900 and 28 Feb 2100 you may use the following method: Code: Count Jan and Feb as month 13 and 14 of the previous year: A 15C program can be done in a few minutes: Code: 001 LBL D This way day [ENTER] month [ENTER] year f[D] returns N(date). Since the uppermost stack register is preserved, the number of days between two dates can be determined easily: 28 [ENTER] 2 [ENTER] 2100 f[D] => 767146 1 [ENTER] 3 [ENTER] 1900 f[D] => 694098 [–] => 73048 Dieter Edit: changed program slightly (omitted DSE 0 and RCLx 0) so that it can also be used with most traditional RPN HPs. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)