System.DateUtils.YearsBetween
Delphi
function YearsBetween(const ANow, AThen: TDateTime): Integer;
C++
extern DELPHI_PACKAGE int __fastcall YearsBetween(const System::TDateTime ANow, const System::TDateTime AThen);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.DateUtils.pas System.DateUtils.hpp |
System.DateUtils | System.DateUtils |
Description
Returns the approximate number of years between two specified TDateTime values.
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 January 1 and December 31 as 0 on non-leap years and 1 on leap years.
YearsBetween always returns a positive result and therefore the parameter values are interchangeable.
See Also