DateTime.AddHours

Syntax

AddHours(Value: DateTime; Count: Integer): DateTime;

Parameters

Value. Initial date

Count. The number of added hours.

Description

The AddHours method adds the specified number of hours to the initial date.

Example

Sub UserProc;
Var
    DT, DT1, DT2, DT3, DT4: DateTime;
Begin
    DT := DateTime.Parse("01.01.2004 10:20:20");
    DT1 := DateTime.AddHours(DT, 1);
    DT2 := DateTime.AddHours(DT, -3);
    DT3 := DateTime.AddHours(DT, 190);
    DT4 := DateTime.AddHours(DT, -590);
End Sub UserProc;

After executing the example the "DT", "DT1", "DT2" and "DT3" and "DT4" variables contain the following values:

"DT" - "01.01.2004 10:20:20"

"DT1" - "01.01.2004 11:20:20"

"DT2" - "01.01.2004 7:20:20"

"DT3" - "09.01.2004 8:20:20"

"DT4" - "07.12.2003 20:20:20"

See also:

DateTime