Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
sunny_talwar

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')

hic
Former Employee
Former Employee

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'.

HIC