Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi , I am beginner with Qlik ! I'm trying to convert seconds hours and minutes HH: MM , but errors in the conversion, put 3 examples below. If anyone can help , thank you.
Why not usee the Interval#() function?
Like Interval#([Qtd Segundos Inicial], 'ss') will also accept seconds outside of the typical 00-59 bounds and convert them to proper DateTime values.
Best,
Peter
Hi Monrow,
assuming that you want to display time calculated from seconds you can do like this:
=time(Time#(SECONDS AMOUNT,'s'),'HH:mm:ss')
Examples:
=time(Time#(60,'s'),'HH:mm:ss') '60 seconds will return 00:01:00 (one minute)
=time(Time#(3600,'s'),'HH:mm:ss') '3600 seconds will return 01:00:00 (one hour)
=time(Time#(46500,'s'),'HH:mm:ss') '46500 seconds will display 12:55:00
If you need in HH:MM
Just change the format and that's it, low change impact and les code.
Examples for HH:MM
=time(Time#(60,'s'),'HH:mm') '60 seconds will return 00:01 (one minute)
=time(Time#(3600,'s'),'HH:mm') '3600 seconds will return 01:00 (one hour)
=time(Time#(46500,'s'),'HH:mm') '46500 seconds will display 12:55
Id this what you are looking for?
Kind regards,
Hi Monrou
Try this will give the Time in HH:MM only
=Time(floor($(vSeconds)/3600) & ':' & Floor(($(vSeconds)/3600 - floor($(vSeconds)/3600) )*60 ),'HH:MM')
Thanks
Monrou:
DateTimes in QV are in the form ddddd.ppppp, where ddddd is the number of days since the '0' date, and ppppp is the fractional part of the day (ie, the time). So to get the HH:mm:ss to display from a number of seconds (nnnnn), you will need to do the following calculation:
nnnnn / (60*60*24) 'where 60 seconds times 60 minutes times 24 hours = # of seconds in a day)
or
nnnnn / 86400
You can then take that value and let QV interpret it as a time, as in:
time((nnnnn/86400),'HH:mm:ss')
to display a time interval in 24-hour format. Please remember though that QV will internally store your value as both a number and a text translation.