Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Difference between two dates (in hours)

I have a date column, let's say Order_Date, which comes from the load of an excel sheet through one of my scripts.This column is a date and its format is DD/MM/YYYY.

What I would like to do is calculate the difference between the maximum and minimum dates in hours. So I have done the following:

(Interval(Max(Order_Date)-Min(Order_Date),'DD') * 24

Is that correct?

2 Replies

Re: Difference between two dates (in hours)

This should work

Interval(Max(Order_Date) - Min(Order_Date),'DD') * 24

or you can try this:

Interval(Max(Order_Date) - Min(Order_Date), 'h')


Re: Difference between two dates (in hours)

The Interval() function is just a formatting function, so you don't need it in Sunny's first formula. (Doesn't do anything bad, either...). So if you use

(Max(Order_Date) - Min(Order_Date)) * 24

you will get a number corresponding to the number of hours.

And if you use

Interval(Max(Order_Date) - Min(Order_Date), 'h')

you will get the number of days, but formatted as hours. E.g. if the difference between min and max is exactly 10 days, the underlying value will be 10, but its textual representation will be '240'.


Community Browser