Use following Pascal functions todo
DateTime operation:
procedure DecodeDate(Date: TDateTime;
var Year, Month, Day: Word);
function EncodeDate(Year, Month, Day: Word): TDateTime;
procedure DecodeTime(Time: TDateTime;
var Hour, Min, Sec, MSec: Word);
function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
TwoHoursLater: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeTime(Present, Hour, Min, Sec, MSec);
Hour := Hour + 2;
if Hour > 24 then
begin
Hour := Hour - 24;
Present := Present + 1;
end;
TwoHoursLater := Int(Present);
TwoHoursLater := TwoHoursLater + EncodeTime(Hour, Min, Sec, MSec);
ShowMessage('The time after 2 hours is ' + DateTimeToStr(TwoHoursLater));
end;