Hi,
I have a rule which returns the process duration in interval format.
now()- ri!processStartTime - Given 07/01/2019 1:27 PM as the process start time, it returns
396::00:50:49.264 (which is in day to second format). How do i display this in years, days, hrs, mins?
For eg:
Discussion posts and replies are publicly visible
I have a simpler version as well that just parses out that duration format, based on a decimal representation of datetime difference, feel free to try it out.
rule!durationFromDecimal()
with( local!interval: tointervalds(ri!duration), local!days: tointeger(split(tostring(local!interval),"::")[1]), local!hours: tointeger(split(tostring(local!interval),":")[3]), local!minutes: tointeger(split(tostring(local!interval),":")[4]), local!seconds: tointeger(split(tostring(local!interval),":")[5]), if( local!days = 0, "", local!days & if(local!days = 1, " day, ", " days, ") ) & if( and(local!days=0, local!hours=0), "", local!hours & if(local!hours = 1," hour, "," hours, ") ) & if( and(local!days = 0, local!hours = 0, local!minutes = 0), "", local!minutes & if(local!minutes = 1," minute, "," minutes, ") ) & local!seconds & if(local!seconds = 1," second"," seconds") )
To test is out:
load( local!date1: now(), local!date2: now(), a!boxLayout( contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!dateTimeField( label: "Date 1", value: local!date1, saveInto: local!date1 ) } ), a!columnLayout( contents: { a!dateTimeField( label: "Date 2", value: local!date2, saveInto: local!date2 ) } ), a!columnLayout( contents: { a!textField( readOnly: true, label: "Duration", value: rule!durationFromDecimal(local!date2-local!date1) ) } ) } ) } ) )
I was able to convert to what i want from these.
Chris & Mike,
Thanks for your help.