WithinPastYears indicates True if two TDateTime values are within the specified AYears number of years of each other.
WithinPastYears is used to determine whether the date specified by ANow is within AYears years of the date specified by AThen.
Fractional years do not count, so if ANow and AThen are two and a half years apart, calling WithinPastYears with AYears set to 2 returns True.
Declaration: function WithinPastYears(const ANow, AThen: TDateTime; const AYears: Integer): Boolean;
An example.