<?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: How convert date to period in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113339#M17556</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Load script like this:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15397957791451379" jivemacro_uid="_15397957791451379"&gt;
&lt;P&gt;Data:&lt;/P&gt;
&lt;P&gt;LOAD Date,&lt;/P&gt;
&lt;P&gt;Year(AddMonths(Date, -3))*100 + Month(AddMonths(Date, -3)) AS Period&lt;/P&gt;
&lt;P&gt;INLINE [&lt;/P&gt;
&lt;P&gt;Date&lt;/P&gt;
&lt;P&gt;01/06/2018 00:00:00&lt;/P&gt;
&lt;P&gt;30/06/2018 00:00:00&lt;/P&gt;
&lt;P&gt;31/01/2018 00:00:00&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will return these values:&lt;/P&gt;&lt;TABLE bgcolor="#ffffff" border="1" cellpadding="2" cellspacing="0" style="font-size: 9pt;"&gt;&lt;TBODY&gt;&lt;TR bgcolor="#f5f5f5"&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Period&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff" nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;31/01/2018 00:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;201710&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff" nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;01/06/2018 00:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;201803&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff" nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;30/06/2018 00:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;201803&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your timestamps are formatted like that, you'll need to make sure this variable is set appropriately:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15397958299593338 jive_text_macro" jivemacro_uid="_15397958299593338"&gt;
&lt;P&gt;SET TimestampFormat='DD/MM/YYYY hh:mm:ss';&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Oct 2018 17:03:53 GMT</pubDate>
    <dc:creator>Nicole-Smith</dc:creator>
    <dc:date>2018-10-17T17:03:53Z</dc:date>
    <item>
      <title>How convert date to period</title>
      <link>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113337#M17554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have a group of dates that I want to convert in my load script to periods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example&amp;nbsp;&amp;nbsp;&amp;nbsp; Anything from 01/06/2018 00:00:00&amp;nbsp; to 30/06/2018 00:00:00&amp;nbsp;&amp;nbsp; would be classed as 201803&lt;/P&gt;&lt;P&gt;The reason being that the year end is 31/3 so period 1 is 1 April- 30 April&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would I convert these in the script?&amp;nbsp; Also as an example 31/01/2018 would be 201710 as it is from the last year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that makes sense&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 16:47:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113337#M17554</guid>
      <dc:creator>paul_ripley</dc:creator>
      <dc:date>2018-10-17T16:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: How convert date to period</title>
      <link>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113338#M17555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(num(month(Date)) &amp;gt; 3, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year(Date) &amp;amp; num((num(month(Date)) - 3),'00'),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (year(Date) - 1) &amp;amp; num((9 + num(month(Date))),'00')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) as financialmonth,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 16:58:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113338#M17555</guid>
      <dc:creator>lorenzoconforti</dc:creator>
      <dc:date>2018-10-17T16:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: How convert date to period</title>
      <link>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113339#M17556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Load script like this:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15397957791451379" jivemacro_uid="_15397957791451379"&gt;
&lt;P&gt;Data:&lt;/P&gt;
&lt;P&gt;LOAD Date,&lt;/P&gt;
&lt;P&gt;Year(AddMonths(Date, -3))*100 + Month(AddMonths(Date, -3)) AS Period&lt;/P&gt;
&lt;P&gt;INLINE [&lt;/P&gt;
&lt;P&gt;Date&lt;/P&gt;
&lt;P&gt;01/06/2018 00:00:00&lt;/P&gt;
&lt;P&gt;30/06/2018 00:00:00&lt;/P&gt;
&lt;P&gt;31/01/2018 00:00:00&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will return these values:&lt;/P&gt;&lt;TABLE bgcolor="#ffffff" border="1" cellpadding="2" cellspacing="0" style="font-size: 9pt;"&gt;&lt;TBODY&gt;&lt;TR bgcolor="#f5f5f5"&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Period&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff" nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;31/01/2018 00:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;201710&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff" nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;01/06/2018 00:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;201803&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff" nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;30/06/2018 00:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;201803&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your timestamps are formatted like that, you'll need to make sure this variable is set appropriately:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15397958299593338 jive_text_macro" jivemacro_uid="_15397958299593338"&gt;
&lt;P&gt;SET TimestampFormat='DD/MM/YYYY hh:mm:ss';&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 17:03:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113339#M17556</guid>
      <dc:creator>Nicole-Smith</dc:creator>
      <dc:date>2018-10-17T17:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: How convert date to period</title>
      <link>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113340#M17557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another way to do it (if it won't break other pieces of your data) is to set the FirstMonthOfYear variable to 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can read more about that here: &lt;A href="https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/NumberInterpretationVariables/FirstMonthOfYear.htm" title="https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/NumberInterpretationVariables/FirstMonthOfYear.htm"&gt;https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/NumberInterpretationVariables/FirstMonthOf…&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 17:20:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113340#M17557</guid>
      <dc:creator>Nicole-Smith</dc:creator>
      <dc:date>2018-10-17T17:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: How convert date to period</title>
      <link>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113341#M17558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;..thanks so much for your help.&amp;nbsp; I haven't had chance to put into my app yet but i'll let you now how I get on when I get a chance, thanks again Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2018 10:18:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-convert-date-to-period/m-p/113341#M17558</guid>
      <dc:creator>paul_ripley</dc:creator>
      <dc:date>2018-10-25T10:18:03Z</dc:date>
    </item>
  </channel>
</rss>

