Examples Delphi

A Delphi implementation of a useful VB function
type
TDateAddUnit = (daYears, daMonths, daDays);
function DateAdd(ADate: TDateTime; Quantity: Integer; AUnit: TDateAddUnit): TDateTime;
var
TimePart: TDateTime;
begin
Result := Trunc(ADate);
TimePart := ADate - Trunc(ADate);
case AUnit of
daYears:
IncMonth(ADate, 12 * Quantity);
daMonths:
IncMonth(ADate, Quantity);
else
Result := ADate + Quantity;
end;
Result := Result + TimePart;
end;