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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
kris_vliegen
Partner - Creator III
Partner - Creator III

Calculating time in script

Hi All,

 

I'm having a problem with calculating time.

In our planning-tooldatabase I have 2 time fields. (Planned time and the time spend)

Those are numeric for example if you get 16 hours in the database we zee 1600, if you get 2h and a half you se 230 in the database.

I can create a timefield in the script by using those 2 

Interval((left(num(PlannedTime,'0000'),2) * 60 + Mid(num(PlannedTime,'0000'),3,2))/24/60,'hh:mm') as PlannedTimehhmm,
Time((left(num(PlannedTime,'0000'),2) * 60 + Mid(num(PlannedTime,'0000'),3,2))/24/60,'hh:mm') as PlannedTimeTijdhhmmTime

And the same for the SpendTime.

But how can I subtract those fields so I get the time that is available for this order?

Regards,

Kris

Labels (2)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Well, try this:

=interval(PlannedTimehhmm-Sum(Spendtime.URSpendTimehhmm), 'hh:mm')

View solution in original post

5 Replies
tresesco
MVP
MVP

Could you provide a sample data and expected output for that?

kris_vliegen
Partner - Creator III
Partner - Creator III
Author

Hi,

attached you can find an example.

Hope this is enough.

tresesco
MVP
MVP

Sorry, I am lost in your sample. Could you tell me what is expected output for two values you mentioned in op, 1600  (16 hours) and 230( 2 hours 30 mins)? 13 hours 30 mins right. 

 You could try like:

=interval(Time#(1600, 'hhmm')-Time#(230, 'hmm'), 'hh:mm')

kris_vliegen
Partner - Creator III
Partner - Creator III
Author

In this example the planned time is 8 h ( 08:00)

and the person has spend once 20 min and once 30 min -> together 00:50

So the value I would like to see as difference is 07:10

tresesco
MVP
MVP

Well, try this:

=interval(PlannedTimehhmm-Sum(Spendtime.URSpendTimehhmm), 'hh:mm')