Time - time = integer.
I have 4 fields
- No.
- From Time
- To Time
- Response
i use code like this → Response := “To Time” - “From Time”;
what’s wrong with this?
it should be [data type time] - [data type time] = [data type integer]
Time - time = integer.
I have 4 fields
i use code like this → Response := “To Time” - “From Time”;
what’s wrong with this?
it should be [data type time] - [data type time] = [data type integer]
There is nothing wrong with it. Subtracting a time from another time results in an integer that contains the difference in milliseconds.
have you tried it?
Yes, and it is working since I have the datatype Time. Same with DateTime.
OBJECT Codeunit 55555 Time
{
OBJECT-PROPERTIES
{
Datum=06.02.08;
Zeit=12:44:04;
Ge„ndert=Ja;
Versions Liste=;
}
PROPERTIES
{
OnRun=BEGIN
Time1 := TIME;
Datetime1 := CURRENTDATETIME;
SLEEP(600);
Time2 := TIME;
Datetime2 := CURRENTDATETIME;
Result := Time2 - Time1;
MESSAGE('Diff. time '+FORMAT(Result));
Result := Datetime2 - Datetime1;
MESSAGE('Diff. datetime '+FORMAT(Result));
END;
}
CODE
{
VAR
Time1@1000000000 : Time;
Time2@1000000001 : Time;
Result@1000000002 : Integer;
Datetime1@1000000003 : DateTime;
Datetime2@1000000004 : DateTime;
BEGIN
END.
}
}
interesting !!
i tried your code
thanx
Fine. But please don’t forget that the result is in miliseconds (as Alain said already).
Ok thanks
I already divide it, so it would be a “second”
…to display the result in a more “readable” way:
tiFrom := TIME;
…
tiTill := TIME;
tiDiff := 0.0T + (toTill - tiFrom);
MESSAGE(
‘%1 ÷ %2 = %3’,
tiTill,
tiFrom,
FORMAT(tiDiff, 0, ‘<hours24,2>:<minutes,2>:<Seconds,2>’) //…or whatever format wanted
);