Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

convert seconds in h:mm:ss

i have a field having time in Seconds, i want to convert it to h:mm:ss,

Please suggest the best approach

Regards

12 Replies
deepakk
Partner - Specialist III
Partner - Specialist III

hi,

this might help you.

=time(Seconds/3600,'hh:mm')

Not applicable
Author

hi Deepak,

take an example 7270 seconds, by ur formula ..

=time(7270/3600,'hh:mm:ss').

Its giving incorrect result.

take it as the exmple ,, it should give 2 hours 1 min and 10 seconds.

Anonymous
Not applicable
Author

Try this one:

=time(Time#(7270,'s'))

Not applicable
Author

Hi Surender,

You have to use time() function along with hh:mm:ss format in your script.

like

suppose your fieldname is timeinseconds then

time(timeinseconds,'hh:mm:ss') as timeinhour

Regards,

Yogesh

Not applicable
Author

Thanks a lot Johnnes

tresesco
MVP
MVP

Hi Sir,

what deepak said is right with a little mistake. it would be

Time(7270/(3600*24),'hh:mm:ss')

Regards, tresesco



Not applicable
Author

thnx .. dear Tresesco..

Anonymous
Not applicable
Author

I had to do a similar thing. I had time in seconds and needed to convert to HH:MM:SS. Tresesco's function works and should be marked as a solution to this problem. This question is currently marked as "not answered".

On the load script, I had a field called "timeinseconds". I created a new field called "hmstime". I can then do time math on this field.


num(div(timeinseconds,3600),00) & ':' & num((div(timeinseconds,60)-(div(timeinseconds,3600)*60)),00) & ':' & num(mod(timeinseconds,60),00) as hmstime


On my form I put a list box with an expression as the only field to calculate the length of the selected items.

='Duration: ' & time(sum(hmstime),'hh:mm:ss')

Tresesco's function Time(timeinseconds/3600*24),'hh:mm:ss') worked great and was simpler than my math.

natebrunner
Contributor III
Contributor III

Thanks..worked great.