SmartPascal
IncMonth
Function
Increments a TDateTime variable by a number of months SysUtils unit
 function IncMonth ( const StartDate : TDateTime {; NumberOfMonths : Integer = 1} ) : TDateTime;
Description
The IncMonth function returns a TDateTime value that is NumberOfMonths greater than the passed StartDate value.
 
The time component of the StartDate value is passed unchanged to the output value.
 
The year value is incremented as appropriate.
 
The increment value is optional, being 1 by default.
 
After incrementing the month, if the day value is too high for that month/year, then it is reduced to the highest value for that month/year.
Notes
There is no DecMonth function.

Instead, use IncMonth with a negative increment.
Related commands
IncDay Increments a TDateTime variable by + or - number of days
IncMinute Increments a TDateTime variable by + or - number of minutes
IncYear Increments a TDateTime variable by a number of years
IncSecond Increments a TDateTime variable by + or - number of seconds
IncMillisecond Increments a TDateTime variable by + or - number of milliseconds
 
Example code : Add values to an example date
var
  myDate : TDateTime;
begin
  myDate := StrToDate('31/01/2000');   // End of Jan in a leap year
  ShowMessage('myDate = '+DateToStr(myDate));

  // Increment by 1 (default)
  // 31st Jan 2000 ==> 31st Feb 2000 (illegal) ==> 29th Feb 2000
  myDate := IncMonth(myDate);
  ShowMessage('myDate + 1 month = '+DateToStr(myDate));

  // Increment by 12 months
  // 29th Feb 2000 ==> 29th Feb 2000 (illegal) ==> 28th Feb 2001
  myDate := IncMonth(myDate, 12);      // Increment by 12 months
  ShowMessage('myDate + 12 months = '+DateToStr(myDate));
end;
Show full unit code
   myDate = 31/01/2000
   myDate + 1 month = 29/02/2000
   myDate + 12 months = 28/02/2001