<?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 Monthtodate variable problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166705#M38562</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;YearToDate only gives you the option to specify a month number - not a particular date in that month.&lt;/P&gt;&lt;P&gt;For that level of fine control, you need to use InMonthToDate:&lt;/P&gt;&lt;P&gt;InMonthToDate&lt;A id="InMonthToDate" name="InMonthToDate"&gt;&lt;/A&gt; ( date, basedate , shift )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Aug 2009 21:21:46 GMT</pubDate>
    <dc:creator>stephencredmond</dc:creator>
    <dc:date>2009-08-26T21:21:46Z</dc:date>
    <item>
      <title>Monthtodate variable problem</title>
      <link>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166700#M38557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi *,&lt;BR /&gt;&lt;BR /&gt;I read the blog entry from Stephen Redmond about Yeartodate.&lt;BR /&gt;&lt;BR /&gt;I'm setting the today date in a variable v_today.&lt;BR /&gt;&lt;BR /&gt;Yeartodate and last yeartodate are working fine:&lt;BR /&gt;&lt;BR /&gt; YearToDate(Date , 0, 1, $(v_today))*-1 AS Cal_YTD_Current&lt;BR /&gt; YearToDate(Date , -1, 1, $(v_today))*-1 AS Cal_YTD_Previous&lt;/P&gt;&lt;P&gt;AS soon as I'm working with Monthtodate and a variable instead of today() I stumble:&lt;/P&gt;&lt;P style="font-weight: bold"&gt;YearToDate(Date , 0, Month(today()))*-1 AS Cal_MTD_Current,&lt;BR /&gt; YearToDate(Date , -1, Month(today()))*-1 AS Cal_MTD_Previous1,&lt;BR /&gt; YearToDate(Date , -2, Month(today()))*-1 AS Cal_MTD_Previous2&lt;/P&gt;&lt;P&gt;-&amp;gt; works fone&lt;/P&gt;&lt;P&gt;Now I tried to use a variable instead of today e.g. v_date = '01.02.2008'&lt;/P&gt;&lt;P&gt;YearToDate(Date , 0, Month($(v_date)))*-1 AS Cal_MTD_Current,&lt;BR /&gt; YearToDate(Date , -1, Month($(v_date)))*-1 AS Cal_MTD_Previous1,&lt;BR /&gt; YearToDate(Date , -2, Month($(v_date)))*-1 AS Cal_MTD_Previous2&lt;/P&gt;&lt;P&gt;I'm getting this:&lt;/P&gt;&lt;P&gt;Cal_MTD_Current: only 0&lt;BR /&gt;Cal_MTD_Previous1: Feb, Mar 08&lt;BR /&gt;Cal_MTD_Previous2: Feb - Aug 07&lt;/P&gt;&lt;P&gt;Can someone tell me what's wrong with this. Thank you.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 15:26:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166700#M38557</guid>
      <dc:creator />
      <dc:date>2009-08-26T15:26:30Z</dc:date>
    </item>
    <item>
      <title>Monthtodate variable problem</title>
      <link>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166701#M38558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This appears to be related to your other post.&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;YearToDate(Today() , 0, Month('$(v_date)'))*-1;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Dates as variables in script can be tricky. I prefer to cast them as Numbers because then I don't have to mess around with string quotes like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt; LET v_date = num(date#('08/14/2009','MM/DD/YYYY'));&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 16:12:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166701#M38558</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2009-08-26T16:12:40Z</dc:date>
    </item>
    <item>
      <title>Monthtodate variable problem</title>
      <link>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166702#M38559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stephen,&lt;/P&gt;&lt;P&gt;thanks for your help. It works perfect as long as my today variable is in current month (Aug).&lt;BR /&gt;As soon as I set my v_date to e.g. 01.02.2009 I get all months to current. Did I misunderstand something?&lt;BR /&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 16:45:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166702#M38559</guid>
      <dc:creator />
      <dc:date>2009-08-26T16:45:01Z</dc:date>
    </item>
    <item>
      <title>Monthtodate variable problem</title>
      <link>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166703#M38560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;When you specify a start month in the YearToDate function (the default is, obviously, 1), the function will only return true of the date passed is in that month or subsequent months. Basically what it is doing is shifting the beginning of the year from 1 = January to another month.&lt;/P&gt;&lt;P&gt;Does that help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 17:10:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166703#M38560</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2009-08-26T17:10:07Z</dc:date>
    </item>
    <item>
      <title>Monthtodate variable problem</title>
      <link>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166704#M38561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stephen,&lt;/P&gt;&lt;P&gt;yes and no &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm trying to set the enddate manually. Instead of today() I'm trying to use the value of v_date.&lt;/P&gt;&lt;P&gt;e.g. if v_date = '15.07.2009' the sales values from 01.07.2009 to 15.07.2009 should be used.&lt;BR /&gt;Did I get something wrong concerning the use of monthtodate?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 17:46:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166704#M38561</guid>
      <dc:creator />
      <dc:date>2009-08-26T17:46:25Z</dc:date>
    </item>
    <item>
      <title>Monthtodate variable problem</title>
      <link>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166705#M38562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;YearToDate only gives you the option to specify a month number - not a particular date in that month.&lt;/P&gt;&lt;P&gt;For that level of fine control, you need to use InMonthToDate:&lt;/P&gt;&lt;P&gt;InMonthToDate&lt;A id="InMonthToDate" name="InMonthToDate"&gt;&lt;/A&gt; ( date, basedate , shift )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 21:21:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Monthtodate-variable-problem/m-p/166705#M38562</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2009-08-26T21:21:46Z</dc:date>
    </item>
  </channel>
</rss>

