Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Converting seconds to hh:mm:ss

seelan89
6 - Meteoroid

Hi All,

 

I am trying to convert seconds from an integer format into HH:MM:SS. Any suggestions?

 

Thanks

5 REPLIES 5
jdunkerley79
ACE Emeritus
ACE Emeritus

Assuming less than 24 hours. I suggest a formula tool creating a Time column:

DateTimeAdd("1900-01-01",[seconds],"seconds")

 

To cope with more than that I suggest. Same formula producing a DateTime as a string. Then a second formula step getting days difference and adding to hours. 

PadLeft(ToString(
DateTimeDiff([Time],"1900-01-01","days")*24
+ ToNumber(Substring([Time],11,2))
), 2,"0") 
+ Substring([Time],13,8)

Sample attached

LordNeilLord
15 - Aurora

Or you can do:

 

PadLeft(ToString(Mod([Seconds]/3600,3600)),2,"0")+":"+

PadLeft(ToString(Mod([Seconds]/60,60)),2,"0")+":"+

PadLeft(ToString(Mod([Seconds],60)),2,"0")

 

jdunkerley79
ACE Emeritus
ACE Emeritus

Merge the two :)

PadLeft(ToString(Floor([Seconds]/3600)),2,"0") +
Right(DateTimeAdd("1900-01-01",[seconds],"seconds"),6)

Should work for all time periods.

seelan89
6 - Meteoroid

thank you both, will try this out.

 

swilson9
6 - Meteoroid

Hi all, 

 

I have tried to convert a time int32 (seconds) into hh:mm:ss  where the record as follows 

 

Records    Sum_TimeTaken 

1                10068859

 

How do i convert this time which is in seconds (int32) into hh:mm:ss 

 

 

Labels
Top Solution Authors