Convert second to duration or time

Hi,

How convert second in duration HH:MM:SS, like this :
10145 Secondes = 02:49:05

thanks for your help

Solved Solved
0 6 597
1 ACCEPTED SOLUTION

As per my understanding, it needs to be done through a constructed expression. However, there could be a much more efficient way. So please wait for any more inputs from the community.

The below will do the job, even though needs to be tested well. Please do test well.
[SecondsColumn] will input the secondsโ€™ value in integer format.

CONCATENATE (
IF([SecondsColumn]>3599, FLOOR([SecondsColumn]/3600),0),":", 

RIGHT("00"&MOD(([SecondsColumn] - MOD([SecondsColumn],60))/60,60),2),":",

RIGHT("00"&MOD([SecondsColumn],60),2)
)

View solution in original post

6 REPLIES 6

As per my understanding, it needs to be done through a constructed expression. However, there could be a much more efficient way. So please wait for any more inputs from the community.

The below will do the job, even though needs to be tested well. Please do test well.
[SecondsColumn] will input the secondsโ€™ value in integer format.

CONCATENATE (
IF([SecondsColumn]>3599, FLOOR([SecondsColumn]/3600),0),":", 

RIGHT("00"&MOD(([SecondsColumn] - MOD([SecondsColumn],60))/60,60),2),":",

RIGHT("00"&MOD([SecondsColumn],60),2)
)

Correct!

Similar expression can be found here:

Hi @Steve

Nice. The expression in the help article and the above one are principally similar. The one in the help article computes from hours to duration, so it has more multiplications ( by 60). The above expression goes the other way round, from seconds to duration, so it has more divisions ( by 60)

Initially, I tried to evaluate TOTALSECONDS(), TOTALMINUTES() etc. functions. But then realized, it probably needs to be built from basic functions.

Thank you for your insight that, yes, it needs to be built that way.

thanks for all

Here's my little contribution to this discussion.  First, my goal:  I wanted an expression that would produce the following, depending on the number of seconds:

1:03
21:03
5:21:03
15:21:03
2:15:21:03

In the last instance, the amount of time indicated is 2 days, 15 hours, 21 minutes, and 3 seconds.  This required a slightly more complex expression.  Here it is:

 

 

concatenate(
if([Number of seconds]<(60*60*24),"",floor([Number of seconds]/(60*60*24))&":"),
if([Number of seconds]<60*60,"",right(if([Number of seconds]<60*60*10,"","0")&floor(([Number of seconds]-FLOOR([Number of seconds]/(60*60*24))*(60*60*24))/(60*60)),2)&":"),
right(if([Number of seconds]<60*10,"","0")&floor(([Number of seconds]-(floor([Number of seconds]/(60*60))*60*60))/(60)),2)&":",
right("00"&mod([Number of seconds],60),2))

 

 

I hope this will be helpful to anyone who winds up needing to convert large numbers of seconds into text that will make sense to users.  Though it is different from what you recommended, @Suvrutt_Gurjar, your expression got me started and eventually enabled me to come up with this.

Thank you very much @Kirk_Masden.

Your expression is a great extension to convert seconds into duration in dd:hh:mm:ss format.

Top Labels in this Space