RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
DateUtils.YearsBetween Function

Returns the approximate number of years between two specified TDateTime values.

Pascal
function YearsBetween(const ANow: TDateTime; const AThen: TDateTime): Integer;
C++
int YearsBetween(const TDateTime ANow, const TDateTime AThen);

DateUtils

Call YearsBetween to obtain the difference, in years, between two TDateTime values. Because years are not all the same length (e.g. leap years), YearsBetween returns an approximation based on an assumption of 365.25 days per year. Fractional years are not counted. Thus, for example, YearsBetween reports the difference between Jan 1 and Dec 31 as 0 on non-leap years and 1 on leap years. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!