[fpc-pascal] Re: Possible bug in return value of MonthsBetween function in unit dateutils
funkybeast at pacific.net.sg
Thu Dec 10 12:50:04 CET 2009
Vincent Snijders wrote:
> Funky Beast schreef:
>> When trying to get the number of months between the following dates:
>> 01-06-2009 and 01-08-2008
>> MonthsBetween returns: 9 months.
>> That is clearly wrong (fundamentally counting with my fingers yields
>> 10 months).
>> Looking at the function in dateutils.inc, I copied the function
>> implementation to do a test.
>> Now, if I strip away Trunc() from the function, the result is:
>> Trunc() simply strips away the decimals behind, which returns: 9.
>> I'm wondering if Round() should be used instead of Trunc().
> For such easy question, I use google:
> states that "This number is an approximation, based on an average number
> of days of 30.4375 per month". 9 is approximately 10, so the is behavior
> you see is as documented ;-)
> fpc-pascal maillist -
> fpc-pascal-PD4FTy7X32k2wBtHl531yWD2FQJk+8+b at public.gmane.org
I did read that, but I'm just wondering isn't 9.98767967 more approximate to 10 than 9?
More information about the fpc-pascal