This example converts the Statistics Duration which is returned in seconds to HH:MM:SS readable format but could be used for any situation where this type of conversion is required.
:set &sss = GET_STATISIC_DETAIL(&UC_CAUSE_NR,DURATION)
:define &f_hrs#,float
:define &f_min#,float
:define &s_hrs#,string
:define &s_min#,string
:define &u_hrs#,unsigned
:define &u_min#,unsigned
! Hours
:set &f_hrs# = DIV(&sss,3600)
:set &s_hrs# = CONVERT(string,&f_hrs#)
:set &pt# = STR_FIND(&s_hrs#,".")
:set &pt# = SUB(&pt#,2)
:set &u_hrs# = MID(&s_hrs#,2,&pt#)
! Minutes
:set &xhrs# = MULT(&u_hrs#,3600)
:set &tmp# = SUB(&sss,&xhrs#)
:set &f_min# = DIV(&tmp#,60)
:set &s_min# = CONVERT(string,&f_min#)
:set &pt# = STR_FIND(&s_min#,".")
:set &pt# = SUB(&pt#,2)
:set &u_min# = MID(&s_min#,2,&pt#)
! Seconds
:set &xmin# = MULT(&u_min#,60)
:set &xhrmn# = ADD(&xhrs#,&xmin#)
:set &sec# = SUB(&sss,&xhrmn#)
! Format results
:set &s_hrs# = FORMAT(&s_hrs#,'00')
:set &s_min# = FORMAT(&s_min#,'00')
:set &sec# = FORMAT(&sec#,'00')
:set &runtime# = &s_hrs#:&s_min#:&sec#
:print Elapsed Time: &runtime#

The implicit rounding is due to the implicit typing. If no type is defined all variables are treated as strings - unsigned with truncated decimal values. Use :DEFINE to explicitly define a type and you should get the expected results.

Ok, in version 8 exists no variable types.

The function DIV and MOD are in all other programming languages and in mathematics defined for integer arithmetic. When I use integer values then there is no rounding.

The DIV-functions counts how many times the divisor exists in the dividend, so any rounding is definetly wrong.

So 7 DIV 2 is 3 not 4 as in Version 8.

Why must I declare the variable as float, when the function DIV and MOD are only defined for integer?

Does your example give an other result if &f_hrs# is not defined as float?

In mathematics is your example wrong because you divide through float.

DIV works fine with floats in version 9, and will return a floating point result, provided that the result variable is first declared as a float.

My, how timely. We are stuck on V8 and have the requirement to use the statistic DURATION and display it in days, hours, minutes and seconds. Here is what we came up with and it appears to satisfy our requirements. While not terribly elegant it does appear to produce the desired results in all our test cases thus far.

Hope I haven't missed something (obvious or not)!