Skip to content

IncHour ​

IncHour returns the given date, incremented by the number of hours given as the ANumberOfHours parameter.

ANumberOfHours can be negative, to return a date, earlier by the specified number of hours.

The time of day specified by AValue is copied to the result.

Declaration: Function IncHour(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime;

This is a simple example.

pascal
procedure OnMapEvent(var Value:Variant);
var
  TheDate, ThatDate, BackDate : TDateTime;
begin
 //Returns a date incremented by 10 hours
  TheDate := Now;
  ThatDate := IncHour(TheDate, 10);
  BackDate := IncHour(TheDate,-10);
  LogInfo(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', TheDate));
  LogInfo(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', ThatDate));
  LogInfo(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', BackDate));
end;