Post Reply 
Year(s) Month(s) Day(s) between 2 dates
10-27-2015, 11:25 PM
Post: #27
RE: Year(s) Month(s) Day(s) between 2 dates
(10-27-2015 03:06 PM)fhub Wrote:  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!

I deleted the program in my 34s and re-entered it according to the listing I provided. Then I tried your examples:

(10-27-2015 03:06 PM)fhub Wrote:  Look at the results for the 3 dates that have been mentioned in this thread:
18.071978 to 19.102015 --> 36.1431 instead of 37.0301
14.051643 to 01.091715 --> 71.1518 instead of 72.0318
23.021951 to 05.091999 --> 47.1813 instead of 48.0613

Not even the most simple dates work, where every number in date2 is higher than in date1, although in this case you could even just subtract the 2 dates:
03.052000 to 10.102015 --> 14.1637 (16 months?, 37 days?)

I tried all the above cases, and my program returned all results correctly: 37.0301, 72.0318 and 48.0613. And the last case did not return 14.1637 but 15.0507.

So the error must be on your side. You probably entered the program incorrectly.

(10-27-2015 03:06 PM)fhub Wrote:  And for some special dates the results are complete nonsense:
01.012000 to 01.022000 --> -0.87
31.012015 to 01.032015 --> Domain Error
31.012015 to 01.042015 --> -0.8599

My program correctly returns 0.0100 for the first case and 0.0201 for the third. The weird answers you got must be caused by an error on your side.

The second case indeed throws a Domain Error since the program tried to calculate the difference between 31 February (!) and 1 March 2015. This should get fixed. Also changing the code to the alternative method you prefer is quite simple.

But again, please check the code in your 34s. You must have entered something wrong.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Year(s) Month(s) Day(s) between 2 dates - Dieter - 10-27-2015 11:25 PM



User(s) browsing this thread: 1 Guest(s)