How to display duration that is in day to second format to years,days,hours, mins format in SAIL interface

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: 

07/01/2019 1:27 PM - 1 yr 31 days 48 mins
03/17/2019 11:59 AM - 1 yr 137 days 2 hrs
Here is the interface code and screenshot for your reference.
a!gridTextColumn(
label: "Duration",
field: "pp.startTime",
data: if(local!datasubset.totalCount=0,{},apply(rule!activeProcessDuration(_),index(index(local!datasubset.data,"pp",{}),
"startTime",{})))
)
Any help is much appreciated.
Thanks,
Meena

  Discussion posts and replies are publicly visible

Parents
  • 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. 

Reply Children
No Data