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

Time Conversion - Seconds to HH:MM:SS

Anaz_S
6 - Meteoroid

Hi,

I want to convert the seconds into 60 seconds into 1 minute i.e, 00:01:00
600 seconds into 10 minute i.e., 00:10:00

Thank you in advance

8 REPLIES 8
JosephSerpis
17 - Castor
17 - Castor

Hi @Anaz_S try this syntax in a formula with your field.

 

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

 

Time.PNG

afv2688
16 - Nebula
16 - Nebula

Hello @Anaz_S,

 

is this ok?

 

Untitled.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regards

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Anaz_S,

 

You could use a datetimeadd() function to add the number of seconds and store the value as a time data type.

 

DateTimeAdd('1900-01-01',[Value],'seconds')

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know!

 

Regards,

Jonathan

binay2448
11 - Bolide

One more Solution...

messeaj12
5 - Atom

Hey Jonathan and others, I'm curious if anyone knows why this formula works? Thanks!

 

DateTimeAdd('1900-01-01',[Value],'seconds')

Matthew
11 - Bolide

@messeaj12 

 

there isnt really much to explain. the DateTimeAdd function will take a date, and add a value to it. all you need to do is specify the interval that you're adding

 

DateTimeAdd('1900-01-01', 3600, 'seconds') will add an hour to the base date

 

DateTimeAdd('1900-01-01', 60, 'minutes') will add an hour to the base date

 

DateTimeAdd('1900-01-01', 1, 'hours') will add an hour to the base date

 

DateTimeAdd('1900-01-01', 1, 'days') will add a day to the base date...

 

you can also subtract

 

DateTimeAdd('1900-01-01', -1, 'days') will subtract a day from the base date

 

 

This means that if you see a timestamp of "1900-01-01 05:00:00", then @Anaz_S will know that they have 5 hours' worth of seconds

 

In fact, if they're certain that they'll never have more that 24 hours, then they could just save it at a Time field instead of a DateTime field

messeaj12
5 - Atom

Thanks! I was a little confused by the 1900-01-01 date, but I see now that piece is irrelevant.

munchkin100
7 - Meteor

@afv2688 awesome! your solution worked for me. thank you!

Labels
Top Solution Authors