IncMonth function
Increases the month in a
TDateTime value with a given amount.
Declaration
function IncMonth(const DateTime: TDateTime; NumberOfMonths: Integer=1)
: TDateTimeDescription
IncMonth increases the month number in
DateTime with
NumberOfMonths. It wraps the result as to get a month between 1 and
12, and updates the year accordingly.
NumberOfMonths can be negative,
and can be larger than 12 (in absolute value).Errors
None.
See also
Example: ex15
Program Example15;
{ This program demonstrates the IncMonth function }
Uses sysutils;
Var ThisDay : TDateTime;
Begin
ThisDay:=Date;
Writeln ('ThisDay : ',DateToStr(ThisDay));
Writeln ('6 months ago :',DateToStr(IncMonth(ThisDay,-6)));
Writeln ('6 months from now :' ,DateToStr(IncMonth(ThisDay,6)));
Writeln ('12 months ago :',DateToStr(IncMonth(ThisDay,-12)));
Writeln ('12 months from now :' ,DateToStr(IncMonth(ThisDay,12)));
Writeln ('18 months ago :',DateToStr(IncMonth(ThisDay,-18)));
Writeln ('18 months from now :' ,DateToStr(IncMonth(ThisDay,18)));
End.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
