<p>I would like a code sample for a function that takes a tDateTime and an integer as input and sets the system time using setlocaltime after advancing that tDateTime by (int) months. The time should stay the same.</p>

<p>pseudo code example</p>

<pre><code>SetNewTime(NOW,2);
</code></pre>

<p>The issues I'm running into are rather frustrating.  I cannot use incmonth or similar with a tDateTime, only a tDate, etc.</p>

Below is a complete command-line program that works for me.  Tested in Delphi 5 and 2007.  Why do you say
IncMonth
does not work for TDateTime?
```
```
program OneMonth;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Windows,
  Messages;

procedure SetLocalSystemTime(settotime: TDateTime);
var
  SystemTime : TSystemTime;
begin
  DateTimeToSystemTime(settotime,SystemTime);
  SetLocalTime(SystemTime);
  //tell windows that the time changed
  PostMessage(HWND_BROADCAST,WM_TIMECHANGE,0,0);
end;

begin
  try
    SetLocalSystemTime(IncMonth(Now,1));
  except on E:Exception do
    Writeln(E.Classname, ': ', E.Message);
  end;
end.
```
```