Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Difference between two dates

I would like to know if it is possible with a formula to calculate the difference between two dates.

For example, I have these two dates: 2012-07-05 and 2012-07-11

Now in my chart there should be the number 6 to get to know that for example one order is in progress for 6 days.

Can anyone explain how to do it?

Thanks a lot!

11 Replies
ToniKautto
Employee
Employee

It is really recommend that you format your Date field properly in the load script. This way you can utilize the QlikView date and time functions and make a more efficient and easy to overview implementation.

Keep in mind that a Date value has a numerical part that corresponds to the number of days since 1899-12-30, which means that a larger Date minus a smaller Date will result in the number of days between the Dates.

I do not really see the purpose of the subfield, the following should work to get the difference in number of days;

=num( date#(floor(max(field1)),'YYYYMMDD') - date#(floor(min(field1)),'YYYYMMDD') )

Not applicable
Author

(dayStart(timestamp(EndDate)) - dayStart(timestamp(StartDate))) + If(Day(StartDate) = 1, 1, 0)

see the attached file