RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
DateUtils.IncHour Function

Returns a date/time value shifted by a specified number of hours.

Pascal
function IncHour(const AValue: TDateTime; const ANumberOfHours: Int64 = 1): TDateTime;
C++
TDateTime IncHour(const TDateTime AValue, const Int64 ANumberOfHours = 1);

IncHour returns the value of the AValue parameter, incremented by ANumberOfHours hours. ANumberOfHours can be negative, to return a date and time N hours prior to AValue.  

C++ Examples: 

 

/*
The following example uses FormatDateTime to set the string
variable S to a sentence indicating a meeting time in 3
hours. The sentence has the form "The meeting is on
Wednesday, February 15, 1995 at 2:30 PM."
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  AnsiString S = "The meeting is on ";
  S = S + FormatDateTime("dddd, mmmm d, yyyy ' at ' hh:mm AM/PM", IncHour(Now(), 3));
  Label1->Caption = S;
}

 

Delphi Examples: 

{
The following example uses FormatDateTime to set the string
variable S to a sentence indicating a meeting time in 3
hours. The sentence has the form "The meeting is on
Wednesday, February 15, 2008 at 2:30 PM."
}
procedure TForm1.Button1Click(Sender: TObject);
var S : string;
begin
  S := SysUtils.FormatDateTime(
    '"The meeting is on " dddd, mmmm d, yyyy, " at " hh:mm AM/PM', IncHour(Now(), 3));
  Label1.Caption := S;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!