Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

To get number of hours between 2 dates

Hi,

I have to find the number of hours in between 2 dates i.e. u_resolved_at and opened_at.

How to find this in QlikView Chart

   

numberNo. Of Hoursu_resolved_atopened_at
---
INC000013695260-6/4/2015  7:45:00 AM6/1/2015 10:04:00 AM
INC000013695759-6/1/2015  4:55:00 PM6/1/2015 11:31:00 AM
INC000013696272-6/2/2015  5:14:00 PM6/1/2015  1:13:00 PM

Thanks..

1 Solution

Accepted Solutions
oknotsen
Master III
Master III

In your load script, do something like this:

(opened_at - u_sesolved_at) * 24 as HoursOpen,

May you live in interesting times!

View solution in original post

6 Replies
oknotsen
Master III
Master III

In your load script, do something like this:

(opened_at - u_sesolved_at) * 24 as HoursOpen,

May you live in interesting times!
puttemans
Specialist
Specialist

Hi there,

Try the 'interval' function.

Num#(Interval (u_resolved_at - opened at, 'mm'))/60 as hours

If you need it rounded

round(Num#(Interval (u_resolved_at - opened at, 'mm'))/60 as hours, 0.1) as hours

(you need the Num# to convert the difference in a number)

Kind regards,

Johan

its_anandrjs

Try this

Interval(u_resolved_at - opened_at, 'hh')

Note:- Dates are in proper timestamp format required.

Regards

Anand

effinty2112
Master
Master

Hi Sweta,

number opened_at u_resolved_at Hours Difference
INC0000136952606/1/2015 10:04:00 AM6/4/2015 7:45:00 AM69.68
INC0000136957596/1/2015 11:31:00 AM6/1/2015 4:55:00 PM5.39
INC0000136962726/1/2015 1:13:00 PM6/2/2015 5:14:00 PM28.01

The last column is this expression:

=Floor(24*(

num(Timestamp#(u_resolved_at,'M/D/YYYY  HH:mm:ss TT'))

-

num(Timestamp#(opened_at,'M/D/YYYY HH:mm:ss TT'))

),0.01)

You can adjust the Floor() function to get the degree of accuracy you require.

Not applicable
Author

Thanks.. It worked..

oknotsen
Master III
Master III

Please do not flag your own answer as Helpful, especially when it is not.

I took the liberty of removing the "Helpful" flag.

What you are supposed to do is flag the Correct Answer as Correct Answer and posts that helped you get there (so those that you consider helpful) as Helpful.

Please do the above to close the topic; thank you.

May you live in interesting times!