#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# duration to time

Member Posts: 229
Hi Experts!!
I have a field type duration with value 1132690
I want to pass it to type time 00:00 h. but I can not find any function that does, only text with the format function but that is not what I need, is there any function?

As always thank you very much

• Hoorn, The NetherlandsMember Posts: 300
edited 2019-01-08
aBigInteger := theDurationValue;

aHours := ROUND(aBigInteger / 3600000,1,'<'); //60 minutes in a hour * 60 seconds in a minute * 1000 milliseconds in a second
aBigInteger := aBigInteger MOD 3600000;

aMinutes := ROUND(aBigInteger / 60000,1,'<'); //60 seconds in a minute * 1000 milliseconds in a second
aBigInteger := aBigInteger MOD 60000;

aSeconds := ROUND(aBigInteger / 1000,1,'<'); //1000 milliseconds in a second
aBigInteger := aBigInteger MOD 1000;

aFractions := ROUND(aBigInteger / 10,1,'<');

aValue := FORMAT(aHours,0,'<Integer,2><Filler Character,0>') + ':' +
FORMAT(aMinutes,0,'<Integer,2><Filler Character,0>') + ' h';

• Member Posts: 229
Thanks!! duikmeester,
Then to create the time would be:

MyTime: = aHoursaMinutesT;

Can it be like this?

I need the data in time type to do calculations do not serve me in text
• Member Posts: 229
Thank you so much!!
• Member Posts: 956
BlackTiger wrote: »
DateTimeValue := 0DT + DurationValue;

This will give you a runtime error
The date is not valid.

But
TimeValue := 000000T + DurationValue;

will give you a time value, which, properly formatted, might serve you as a base for displaying as duration provided the duration is short enough (i.e. depending on your time format shorter than 12 or 24 hours). You probably still would need a custom format string to format it sensibly in order to show it, for example, in a column of a table.

Note: 0T gives you an undefined time, 000000T gives you the start of a day.
• Member Posts: 229
Thank you so much!!