DelphiFAQ Home Search:
General :: Programming :: Delphi
General Delphi related information.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Incrementing a date

Sometimes you may need to increment a date by one month.
Simply adding 30 days won't do the trick, since some months do have 31 days.. not to forget the issue with leap years.

But there is a simple solution in SysUtils.pas: this unit provides a routine IncMonth().

Use it as in the following snippet:

var
   OldDate,
   NewDate : TDateTime;
 begin
   OldDate := ..
   // now increment by one month
  NewDate := IncMonth (OldDate, 1);
 end;

Generated 12:01:49 on Jun 22, 2017