<?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: Problems With AddMonths in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998488#M966898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried it without the variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;AddMonths(Today(),-6)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Oct 2015 14:59:09 GMT</pubDate>
    <dc:creator>jpapador</dc:creator>
    <dc:date>2015-10-05T14:59:09Z</dc:date>
    <item>
      <title>Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998486#M966896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;I am having problems all over the place with dates.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;My first problem is that I need a variable to calculate todays date minus six months ago for a LOAD statement WHERE clause.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;I've tried the code below just to set the variable but is all goes horribly wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;In debug I get '05-10-2015' after the first statement but '19-12-1893' after the second statement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Let VarTest = Today();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Let VarTest = AddMonths($(VarTest),-6);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Where am I going wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 14:48:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998486#M966896</guid>
      <dc:creator>rebelfox</dc:creator>
      <dc:date>2015-10-05T14:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998487#M966897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="text-decoration: line-through;"&gt;The first version of VarTest probably contains something like 5/10/2015. Passing this &lt;EM&gt;division&lt;/EM&gt; as-is as a parameter to AddMonths() will not result in a correct value.&lt;/SPAN&gt; Subtractions in your case, not divisions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Put $(VarTest) between single quotes or add num() to the first line, reload and see what happens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Edit]: Wrong feedback. But you get the idea. Use a quoted variable in the second line, or add num() to the first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 14:53:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998487#M966897</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-10-05T14:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998488#M966898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried it without the variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;AddMonths(Today(),-6)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 14:59:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998488#M966898</guid>
      <dc:creator>jpapador</dc:creator>
      <dc:date>2015-10-05T14:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998489#M966899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just remove the $ symbol in the variable, it will work!&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10.6667px;"&gt;Let VarTest = AddMonths(VarTest,-6);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 14:59:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998489#M966899</guid>
      <dc:creator>malini_qlikview</dc:creator>
      <dc:date>2015-10-05T14:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998490#M966900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just remove the dollar expansion:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 8pt; font-family: inherit;"&gt;Let VarTest = Today();&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 8pt; font-family: inherit;"&gt;Let VarTest = AddMonths(VarTest,-6);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 8pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 14:59:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998490#M966900</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2015-10-05T14:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998491#M966901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK both of your examples work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a bit confused over why.&amp;nbsp; Taking your first solution, why is it necessary for the variable to be converted to a number on the first line and why does the subsequent AddMonths change the format from a number back to a date?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 15:00:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998491#M966901</guid>
      <dc:creator>rebelfox</dc:creator>
      <dc:date>2015-10-05T15:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998492#M966902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;My next newbie query relates to the LOAD statement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;I compare a timestamp value on the table to the variable in the hope it would select dates in the last 6 months but the date selection seems to be ignored.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE SA_Changed_Date &amp;gt;= ($VarTest2) AND &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 15:11:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998492#M966902</guid>
      <dc:creator>rebelfox</dc:creator>
      <dc:date>2015-10-05T15:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998493#M966903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes this works as well. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 15:12:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998493#M966903</guid>
      <dc:creator>rebelfox</dc:creator>
      <dc:date>2015-10-05T15:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problems With AddMonths</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998494#M966904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is with the $-sign expansion. DSE replaces $(var) with the content of var. This results in a second statement like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 10pt; font-family: 'courier new', courier;"&gt;Let VarTest = AddMonths(05-10-2015,-6);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;which is an arithmetic expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;AddMonths on the other hand will accept both strings and numerical &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;(and dual()) &lt;/SPAN&gt;values as a first parameter. And return a dual() date value which - depending on the context - can result in the string representation or the numerical value that corresponds to that particular date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"&gt;See also Henric's post down below. He suggests an even better (simpler) alternative.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"&gt;Good luck,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10.6667px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Peter&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Oct 2015 15:14:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-With-AddMonths/m-p/998494#M966904</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-10-05T15:14:54Z</dc:date>
    </item>
  </channel>
</rss>

