Skip to main content
September 20, 2021
Question

Convert seconds to hh:mm:ss

  • September 20, 2021
  • 2 replies
  • 0 views

I need to convert seconds to hh:mm:ss.  For example, 5565 seconds would be displayed as 01:32:45.  Does anyone have a good way to do this?

2 replies

vimals
September 20, 2021

Hope this helps

a!localVariables(
  local!hoursInDecimal: split(5565 / 3600, "."),
  local!minutes:split((todecimal("." & local!hoursInDecimal[2])*60),"."),
  joinarray({text(local!hoursInDecimal[1],"00"), text(local!minutes[1], "00"), text(round(("." & local!minutes[2])*60), "00")}, ":")
  /*time(local!hoursInDecimal[1], local!minutes[1] , round(("." & local!minutes[2])*60))*/
)

September 30, 2021

Conveniently you can also use Appian's  intervalds() function that converts the given time components into an equivalent time duration. Since you only have seconds, you can specify 0's for hour and minute values. e.g. intervalds(0,0,5565) will result 0::01:32:45.000. You can then apply specific formatting as needed. Code snippet be like -

split(split(tostring(intervalds(0,0,5565)), "::")[2],".")[1]