Year(s) Month(s) Day(s) between 2 dates
|
10-27-2015, 03:06 PM
Post: #26
|
|||
|
|||
RE: Year(s) Month(s) Day(s) between 2 dates
Hi,
I've now entered both programs from Dieter and Didier (each in the last updated version), and there must be something wrong with the listings, because both programs don't work correctly! Look at the results for the 3 dates that have been mentioned in this thread: Code:
Quote:03.052000 to 10.102015 --> 14.1637 (16 months?, 37 days?)And for some special dates the results are complete nonsense: Quote:01.012000 to 01.022000 --> -0.87 And now about the problem of 2 different results for Didier's example (23 Feb. 1951 to 5 Sept. 1999): I definitely agree with Gérard that the 'correct' result is 48y/6m/10d and NOT 48y/6m/13d! You can't move forward to 23 Aug 1999, at least NOT for all cases - try your method with the following 2 dates (in any year YYYY): 31 Jan. YYYY to 5 March YYYY You can't move forward to 31 Feb., because Feb. simply doesn't have 31 days! (same problem with 30 or 29 Jan, or if the 2nd month is May/July/Oct/Dec) So in fact Gérard's method is correct, unless you want to make a lot of differences between all kinds of months. In short words: (for d1.m1yyy1 to d2.m2yyy2) If d2<d1, then you have to add the remaining days in m1 and the days d2, and change the first date to the 1st day of the following month. Here's my own (really working! ) version, which uses exactly the method I've described above - you only must take care that the result is also in the same format DD.MMYYYY as the the input dates (therefore the name DMY)! I've made it this way, because 1) IMO it's more consistent if the input and output have the same format, and 2) everything can be done on the 4-level stack (no extra registers needed), so 3) the program is much smaller (only 29 steps!) Quote:0001 LBL'DMY' Franz |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)