Skip to main content
Known Participant
Sep 20, 2021 9:53 PM UTC
Question

Convert seconds to hh:mm:ss

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
Participating Frequently
Sep 20, 2021 10:14 PM UTC

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))*/
)

Participating Frequently
Sep 30, 2021 5:01 PM UTC

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]