<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: date between another date range in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984044#M81184</link>
    <description>&lt;P&gt;Hi Rohit,&lt;/P&gt;
&lt;P&gt;can you clarify your requirements a little bit more?&lt;/P&gt;
&lt;P&gt;You have two date columns. Is [col2_date &amp;lt;= 15 and col2_date &amp;gt;= 1] the name of the second or do you want it to be in that range?&lt;/P&gt;
&lt;P&gt;And what do you mean by col1_date should be in between that field? Do you want all dates in between that range or do you want to check if col1_date is in between the range.&lt;/P&gt;
&lt;P&gt;Let's assume you have a column with a date range and want to check if col1_date is in between that range:&lt;/P&gt;
&lt;P&gt;If you don't have the from and to dates you can calculate them like this (with the range looking like '2022/01/01-2022/01/15'):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Date#(SubField(col2_date, '-', 1), 'YYYY/MM/DD') AS FromDate,
Date#(SubField(col2_date, '-', 2), 'YYYY/MM/DD') AS ToDate,&lt;/LI-CODE&gt;
&lt;P&gt;Then you can just do a simple If Condition:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;If(col1_date &amp;gt;= FromDate and col1_date &amp;lt;= ToDate, 1, 0) AS isInBetween&lt;/LI-CODE&gt;
&lt;P&gt;If you want to get all dates between the range you could use a mastercalendar and intervalmatch:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;AllDates:
Load
    DateKey; //You can calculate all time Fields with this date
Load
    Date(MinDate + IterNo() - 1) AS DateKey
    While (MinDate + IterNo() -1) &amp;lt;= MaxDate;
Load
    Min(FromDate) as MinDate,
    Max(ToDate) as MaxDate
Resident Source;


Left Join(Source) //Based on FromDate and ToDate

DatesBetween:
IntervalMatch(DateKey)
Load Distinct
    FromDate,
    ToDate
Resident Source;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards,&lt;/P&gt;
&lt;P&gt;Johannes&lt;/P&gt;</description>
    <pubDate>Thu, 22 Sep 2022 07:24:14 GMT</pubDate>
    <dc:creator>Dolphin</dc:creator>
    <dc:date>2022-09-22T07:24:14Z</dc:date>
    <item>
      <title>date between another date range</title>
      <link>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1983977#M81175</link>
      <description>&lt;P&gt;&lt;SPAN&gt;col1_date in between [col2_date &amp;lt;=15 and col2_date &amp;gt;=1]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want col1_date between col2_date &amp;lt;=15 and col2_date &amp;gt;=1 this range please provide some logic to build&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rohit&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 04:44:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1983977#M81175</guid>
      <dc:creator>rohit_bibe07</dc:creator>
      <dc:date>2022-09-22T04:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: date between another date range</title>
      <link>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984044#M81184</link>
      <description>&lt;P&gt;Hi Rohit,&lt;/P&gt;
&lt;P&gt;can you clarify your requirements a little bit more?&lt;/P&gt;
&lt;P&gt;You have two date columns. Is [col2_date &amp;lt;= 15 and col2_date &amp;gt;= 1] the name of the second or do you want it to be in that range?&lt;/P&gt;
&lt;P&gt;And what do you mean by col1_date should be in between that field? Do you want all dates in between that range or do you want to check if col1_date is in between the range.&lt;/P&gt;
&lt;P&gt;Let's assume you have a column with a date range and want to check if col1_date is in between that range:&lt;/P&gt;
&lt;P&gt;If you don't have the from and to dates you can calculate them like this (with the range looking like '2022/01/01-2022/01/15'):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Date#(SubField(col2_date, '-', 1), 'YYYY/MM/DD') AS FromDate,
Date#(SubField(col2_date, '-', 2), 'YYYY/MM/DD') AS ToDate,&lt;/LI-CODE&gt;
&lt;P&gt;Then you can just do a simple If Condition:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;If(col1_date &amp;gt;= FromDate and col1_date &amp;lt;= ToDate, 1, 0) AS isInBetween&lt;/LI-CODE&gt;
&lt;P&gt;If you want to get all dates between the range you could use a mastercalendar and intervalmatch:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;AllDates:
Load
    DateKey; //You can calculate all time Fields with this date
Load
    Date(MinDate + IterNo() - 1) AS DateKey
    While (MinDate + IterNo() -1) &amp;lt;= MaxDate;
Load
    Min(FromDate) as MinDate,
    Max(ToDate) as MaxDate
Resident Source;


Left Join(Source) //Based on FromDate and ToDate

DatesBetween:
IntervalMatch(DateKey)
Load Distinct
    FromDate,
    ToDate
Resident Source;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards,&lt;/P&gt;
&lt;P&gt;Johannes&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 07:24:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984044#M81184</guid>
      <dc:creator>Dolphin</dc:creator>
      <dc:date>2022-09-22T07:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: date between another date range</title>
      <link>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984094#M81192</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Johannes thanks for your answer, my requirement is that i want date range from [col2_date&amp;lt;=15 and col2&amp;gt;=1], col2_date is date column like 'DD-MM-YYYY' and another condition is that i want to filter date of col1_date with respect to above condition means if user select date from col2_date then col1_date will be filtered. so the overall condition is that&amp;nbsp; "col1_date inbetween&amp;nbsp;&amp;nbsp;[col2_date&amp;lt;=15 and col2&amp;gt;=1] in this range.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rohit&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 08:28:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984094#M81192</guid>
      <dc:creator>rohit_bibe07</dc:creator>
      <dc:date>2022-09-22T08:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: date between another date range</title>
      <link>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984157#M81204</link>
      <description>&lt;P&gt;What do you mean with &lt;SPAN&gt;col2_date&amp;lt;=15? Do you want to check if the date is &amp;gt;= 15 (Date(15) would return 1900/01/14 as a date)? Or do you want the Date of 15 day ago compared to col2_date?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If you have col2_date and want to create a range with it you could do something like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Load
    col1_date,
    col2_date,
    Date(col2_date -15) &amp;amp; AS FromDate,
    Date(col2_date +1) AS ToDate
    Date(col2_date -15) &amp;amp; Date(col2_date +1) as [col2_date&amp;lt;=15 and col2_date&amp;gt;=1]
From Source
&lt;/LI-CODE&gt;
&lt;P&gt;With these new Dates (FromDate &amp;amp; ToDate) you can again just check if col1_date is in between by creating the If condition in the previous answer.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 10:19:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984157#M81204</guid>
      <dc:creator>Dolphin</dc:creator>
      <dc:date>2022-09-22T10:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: date between another date range</title>
      <link>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984546#M81237</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;
&lt;P&gt;I thought of a use case you might mean.&amp;nbsp;Pls Check the script. Is this the right Direction?&lt;/P&gt;
&lt;P&gt;Basically you can select Date2 as ReferenceDate and get all Date1s that are in between the ReferenceDates Range (and the same Dim!):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Source:
Load * Inline [
Dim, Date1, Date2
A, 2022/01/15, 2022/01/09
A, 2022/01/27, 2022/02/09
A, 2022/02/02, 2022/02/10
B, 2022/03/09, 2022/07/12
B, 2022/07/09, 2022/07/12
C, 2022/03/04, 2022/03/03
];

NoConcatenate

Fact:
Load
    Dim,
    Date#(Date1, 'YYYY/MM/DD') AS Date1,
    Date#(Date2, 'YYYY/MM/DD') AS Date2
Resident Source;
Drop Table Source;

Time_Temp:
Load
    Dim,
    Date2 AS ReferenceDate,
    Date(Date2 - 15, 'YYYY/MM/DD') AS DateFrom,
    Date(Date2 + 1, 'YYYY/MM/DD') AS DateTo
Resident Fact;

Left Join(Time_Temp)

IntervalMatch(Date1, Dim)
Load
    DateFrom,
    DateTo,
    Dim
Resident Time_Temp;

Time:
Load 
    Date1,
    ReferenceDate,
    DateFrom,
    DateTo,
    Dim as ReferenceDim
Resident Time_Temp;
Drop Table Time_Temp;&lt;/LI-CODE&gt;
&lt;P&gt;Kind Regards,&lt;/P&gt;
&lt;P&gt;Johannes&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 07:09:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/date-between-another-date-range/m-p/1984546#M81237</guid>
      <dc:creator>Dolphin</dc:creator>
      <dc:date>2022-09-23T07:09:47Z</dc:date>
    </item>
  </channel>
</rss>

