From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function YearSpan(const ANow, AThen: TDateTime): Double;


extern DELPHI_PACKAGE double __fastcall YearSpan(const System::TDateTime ANow, const System::TDateTime AThen);


Type Visibility Source Unit Parent
function public
System.DateUtils System.DateUtils


Returns the approximate number of years (including fractions thereof) between two specified TDateTime values.

Call YearSpan 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. Unlike the YearsBetween function, which does not report fractional years, YearSpan reports incomplete years as a fraction of a 365.25-day year.

YearSpan always returns a positive result and therefore the parameter values are interchangeable.

See Also

Code Examples