Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

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
Valued Contributor III

convert seconds in h:mm:ss

hi,

this might help you.

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

Not applicable

convert seconds in h:mm:ss

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.

jsn
Honored Contributor

convert seconds in h:mm:ss

Try this one:

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

Not applicable

convert seconds in h:mm:ss

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

convert seconds in h:mm:ss

Thanks a lot Johnnes

MVP
MVP

convert seconds in h:mm:ss

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

convert seconds in h:mm:ss

thnx .. dear Tresesco..

gadgetgeek
New Contributor II

convert seconds in h:mm:ss

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
New Contributor III

Re: convert seconds in h:mm:ss

Thanks..worked great.