[Lazarus] DateDif function needed

Michael Van Canneyt michael at freepascal.org
Sat Nov 9 19:41:33 CET 2013



On Sat, 9 Nov 2013, waldo kitty wrote:

>
> digging deeper to work directly with YearsBetween and MonthsBetween shows 
> that they seem to be missing the usual "+0.5" generally used to ensure that 
> rounding is properly handled...

You misunderstood these functions.

There is no rounding necessary. The routines are correct.

Only FULL years/months/day must be counted.

See the documentation in e.g.

http://www.freepascal.org/docs-html/rtl/dateutils/yearsbetween.html

If you want partial years counted, you need the *Span functions.

http://www.freepascal.org/docs-html/rtl/dateutils/yearspan.html

Michael.




More information about the Lazarus mailing list