Qlik Community

Ask a Question

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Creator III
Creator III

Count overlapping days between two date ranges (Intersections)

Hi,

This is with further reference to below thread;

Insert rows between two date ranges

I want to get the count of days which overlap between below two date ranges. (Inclusive of first and last dates)

Eg. Select vStart_Date   -    Select vEnd_Date  (01-Jan-14 to 04-Jan-14)

     Actual Check In Date  - Actual Check Out Date (02-Jan-14 to 06-Jan-14)

I want to get the overlapping count as 03 days ( 02-Jan-14 to 04-Jan-14 inclusive of both days)

Thank You,

Senarath

1 Solution

Accepted Solutions

RangeMax(0, RangeMin(vEnd_Date,[Actual Check Out Date]) - RangeMax(vStart_Date,[Actual Check In Date]))

View solution in original post

5 Replies
Not applicable

if(e1>e2,e2,e1)-if(s1>s2,s1,s2)+1

is that OK? Assuming s1 = Select vStart_Date, e1 = Select vEnd_Date, s2 = Actual Check In Date, e2 = Actual Check Out Date...

And you should check it for positive results, of course (negative will mean lack of intersection).

RangeMax(0, RangeMin(vEnd_Date,[Actual Check Out Date]) - RangeMax(vStart_Date,[Actual Check In Date]))

View solution in original post

Creator III
Creator III

Hi Alex,

I tried this and did not work because the date selection can be varied according to user. We cannot predefined which date going to be less than what.

Let me try out other answers and give a feedback.

Thanx

Not applicable

How are you going to acquire the dates from user? Control elements that change some variables?

Creator III
Creator III

Hi Marco,

I applied your answer and it works. However, as I wanted both days inclusive, I modified it as below by adding 1

and figures seem ok.

RangeMax(0, RangeMin(vEnd_Date+1,[Actual Check Out Date]+1) - RangeMax(vStart_Date,[Actual Check In Date]))


Hope, technically this is ok.


Many thanks