Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
hosasahana
Partner - Contributor III
Partner - Contributor III

convert string column with hours, minutes and seconds to only seconds, request help!!

hi,

I have a column which is a string and looks as attached. I need to convert this into only seconds so that I can use it in my code eg: wait_time {'<=60'} or wait_time {'>60'} etc.

Please can someone help ?

1 Solution

Accepted Solutions
MayilVahanan

HI @hosasahana 

FYIP, InLine table used for sample purpose. You can try the logic used to calculate the values.

Evaluate(Replace(Replace(Replace(WaitTime, 'Hour', '*3600+'), 'Minutes', '*60'),'Seconds', ''))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

6 Replies
MayilVahanan

HI @hosasahana 

One of way to achieve this like below.. 

Load *, Evaluate(Replace(Replace(Replace(WaitTime, 'Hour', '*3600+'), 'Minutes', '*60'),'Seconds', '')) as WaitSec Inline
[
WaitTime
1 Hour 1 Minutes
1 Hour 2 Minutes
1 Hour 5 Minutes
0 Seconds
13 Minutes
12 Seconds
];

You can change little bit based on ur requirement

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
hosasahana
Partner - Contributor III
Partner - Contributor III
Author

hi Mayil,

thanks for responding,

the wait_time field contains lots of values. Is there any other way other than Inline method ?

MayilVahanan

HI @hosasahana 

FYIP, InLine table used for sample purpose. You can try the logic used to calculate the values.

Evaluate(Replace(Replace(Replace(WaitTime, 'Hour', '*3600+'), 'Minutes', '*60'),'Seconds', ''))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
hosasahana
Partner - Contributor III
Partner - Contributor III
Author

sorry Mayil,its not working 😞 

hosasahana
Partner - Contributor III
Partner - Contributor III
Author

Pl can anyone help me resolve this?

hosasahana
Partner - Contributor III
Partner - Contributor III
Author

thanks 🙂 it works