<?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 Generating Months, Quarters &amp; Years between two dates in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236519#M87695</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I use the following script to do that, don't know if it's the best around. Difference is that I just need dates for de last 4 years, you'll need to assign the variables vStartDate and vEndDate in another way:&lt;/P&gt;&lt;P&gt;(In your fact table, make sure you have the factdate loaded as 'Date' (or the same fieldname as you'll use in the calendar table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vToday=num(Today());&lt;/P&gt;&lt;P&gt;Let vStartDate = num(MakeDate(Year(ToDay()) - 4, 1, 1));&lt;/P&gt;&lt;P&gt;Let vEndDate = num(MakeDate(Year(ToDay()), 12, 31));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*************** Temporary Calendar ***************&lt;/P&gt;&lt;P&gt;TempCalendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;$(vStartDate)+IterNo()-1 as Num,&lt;/P&gt;&lt;P&gt;Date($(vStartDate)+IterNo()-1) as TempDate&lt;/P&gt;&lt;P&gt;AUTOGENERATE 1 WHILE $(vStartDate)+IterNo()-1&amp;lt;= $(vEndDate);&lt;/P&gt;&lt;P&gt;//*************** Master Calendar ******************&lt;/P&gt;&lt;P&gt;Calendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;TempDate as Date,&lt;/P&gt;&lt;P&gt;Year(TempDate) as Year,&lt;/P&gt;&lt;P&gt;Month(TempDate) as Month,&lt;/P&gt;&lt;P&gt;'Q' &amp;amp; Ceil(Month(TempDate)/3) as Quarter,&lt;/P&gt;&lt;P&gt;Week(TempDate) as Week&lt;/P&gt;&lt;P&gt;RESIDENT TempCalendar&lt;/P&gt;&lt;P&gt;ORDER BY TempDate Asc;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yves&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Jan 2011 08:47:58 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-01-04T08:47:58Z</dc:date>
    <item>
      <title>Generating Months, Quarters &amp; Years between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236516#M87692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I have a query regarding creation of period basis the start date and end dates.&lt;/P&gt;&lt;P&gt;ex: I have a contract starts from 20-Dec-2010 and ends 30-jun-2011, then i want to see the information as number of days for each month, qtr &amp;amp; year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me in this asap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Dec 2010 10:25:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236516#M87692</guid>
      <dc:creator />
      <dc:date>2010-12-31T10:25:24Z</dc:date>
    </item>
    <item>
      <title>Generating Months, Quarters &amp; Years between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236517#M87693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to make sure I understand correctly, do you want to generate the years (2010, 2011), months (December, January, February, March, April, May, June) and quarters (Q4, Q1, Q2) for filtering?&lt;/P&gt;&lt;P&gt;Or, do you want to know that the contract will last 0 years, 6 months or 2 quarters? If you want to know how long the contract will last, would your example last 2 quarters, 3 quarters or 2.1 quarters?&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Jan 2011 18:57:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236517#M87693</guid>
      <dc:creator>pover</dc:creator>
      <dc:date>2011-01-02T18:57:08Z</dc:date>
    </item>
    <item>
      <title>Generating Months, Quarters &amp; Years between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236518#M87694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Firstly thank you for the reply Mr. Pover.&lt;/P&gt;&lt;P&gt;Yes I want to know the periods like Q1,Q2,Q3,Q4 and months and year between the contract period mentioned, so that I can show the data as number of days for that month/quarter/year as dimensions&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jan 2011 04:32:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236518#M87694</guid>
      <dc:creator />
      <dc:date>2011-01-04T04:32:03Z</dc:date>
    </item>
    <item>
      <title>Generating Months, Quarters &amp; Years between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236519#M87695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I use the following script to do that, don't know if it's the best around. Difference is that I just need dates for de last 4 years, you'll need to assign the variables vStartDate and vEndDate in another way:&lt;/P&gt;&lt;P&gt;(In your fact table, make sure you have the factdate loaded as 'Date' (or the same fieldname as you'll use in the calendar table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vToday=num(Today());&lt;/P&gt;&lt;P&gt;Let vStartDate = num(MakeDate(Year(ToDay()) - 4, 1, 1));&lt;/P&gt;&lt;P&gt;Let vEndDate = num(MakeDate(Year(ToDay()), 12, 31));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*************** Temporary Calendar ***************&lt;/P&gt;&lt;P&gt;TempCalendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;$(vStartDate)+IterNo()-1 as Num,&lt;/P&gt;&lt;P&gt;Date($(vStartDate)+IterNo()-1) as TempDate&lt;/P&gt;&lt;P&gt;AUTOGENERATE 1 WHILE $(vStartDate)+IterNo()-1&amp;lt;= $(vEndDate);&lt;/P&gt;&lt;P&gt;//*************** Master Calendar ******************&lt;/P&gt;&lt;P&gt;Calendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;TempDate as Date,&lt;/P&gt;&lt;P&gt;Year(TempDate) as Year,&lt;/P&gt;&lt;P&gt;Month(TempDate) as Month,&lt;/P&gt;&lt;P&gt;'Q' &amp;amp; Ceil(Month(TempDate)/3) as Quarter,&lt;/P&gt;&lt;P&gt;Week(TempDate) as Week&lt;/P&gt;&lt;P&gt;RESIDENT TempCalendar&lt;/P&gt;&lt;P&gt;ORDER BY TempDate Asc;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yves&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jan 2011 08:47:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Generating-Months-Quarters-Years-between-two-dates/m-p/236519#M87695</guid>
      <dc:creator />
      <dc:date>2011-01-04T08:47:58Z</dc:date>
    </item>
  </channel>
</rss>

