<?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 LET/SET date question in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/LET-SET-date-question/m-p/166502#M504873</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi *,&lt;/P&gt;&lt;P&gt;I'm setting my "today date" via a variable.&lt;/P&gt;&lt;P&gt;LET v_today = date(date#('08/14/2009','MM/DD/YYYY'),'MM/DD/YYYY');&lt;/P&gt;&lt;P&gt;Further in the Script I'm doing some calculations based on the variable eg. $(v_today) - Datefield AS xyz&lt;/P&gt;&lt;P&gt;If I use the statement Let v_today... I'm getting : Error in expression ')' expected as soon as I use $(v_today).&lt;/P&gt;&lt;P&gt;If i use Set the calculation is done, although v_today is date(date#....&lt;/P&gt;&lt;P&gt;Can someone explain me why this happens?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Aug 2009 14:39:41 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-08-26T14:39:41Z</dc:date>
    <item>
      <title>LET/SET date question</title>
      <link>https://community.qlik.com/t5/QlikView/LET-SET-date-question/m-p/166502#M504873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi *,&lt;/P&gt;&lt;P&gt;I'm setting my "today date" via a variable.&lt;/P&gt;&lt;P&gt;LET v_today = date(date#('08/14/2009','MM/DD/YYYY'),'MM/DD/YYYY');&lt;/P&gt;&lt;P&gt;Further in the Script I'm doing some calculations based on the variable eg. $(v_today) - Datefield AS xyz&lt;/P&gt;&lt;P&gt;If I use the statement Let v_today... I'm getting : Error in expression ')' expected as soon as I use $(v_today).&lt;/P&gt;&lt;P&gt;If i use Set the calculation is done, although v_today is date(date#....&lt;/P&gt;&lt;P&gt;Can someone explain me why this happens?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 14:39:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/LET-SET-date-question/m-p/166502#M504873</guid>
      <dc:creator />
      <dc:date>2009-08-26T14:39:41Z</dc:date>
    </item>
    <item>
      <title>LET/SET date question</title>
      <link>https://community.qlik.com/t5/QlikView/LET-SET-date-question/m-p/166503#M504874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Why are you using the date and date# functions? The date# function by itself will parse the text into the date format that you want.&lt;/P&gt;&lt;P&gt;This statement works very well to assign the variable (and if you look in your document, in the variable overview, you will see the value assigned). I imagine that the error about the ')' is unrelated to the assignment but is related to your use of the value. Instead of $(v_today), you may need to use '$(v_today)'.&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 16:03:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/LET-SET-date-question/m-p/166503#M504874</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2009-08-26T16:03:33Z</dc:date>
    </item>
    <item>
      <title>LET/SET date question</title>
      <link>https://community.qlik.com/t5/QlikView/LET-SET-date-question/m-p/166504#M504875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;(also check Stephen's answer for a solution to your problem; just explaining what's happening exactly here)&lt;/P&gt;&lt;P&gt;The difference between 'set' and 'let' is that 'set' just assigns the text behind the '=' (i.e. the entire expression) to your variable - that's why it contains 'date(date#(...))' later; 'let' evaluates the expression, and assigns the result to your variable.&lt;/P&gt;&lt;P&gt;When you use $(v_today) in the script, QlikView will evaluate the contents to some text value, put that in place of the variable ( $(v_today) ), and then run the resulting script.&lt;/P&gt;&lt;P&gt;If your variable contains a literal date value, this will be added, resulting in something like&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;LOAD&lt;BR /&gt;...&lt;BR /&gt;08/14/2009 as date_field&lt;BR /&gt;...&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;which is interpreted (literally, but incorrectly) as some script calculation. For this case, Stephen suggests putting quotes around the $(v_today), so it gets interpreted as a piece of text instead of some script calculation.&lt;/P&gt;&lt;P&gt;If your variable contains the expression text (what happens in the 'set' statement), you'll end up (after variable substitution) with something like&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;LOAD&lt;BR /&gt;...&lt;BR /&gt;date(date#('08/14/2009','MM/DD/YYYY'),'MM/DD/YYYY') as date_field,&lt;BR /&gt;...&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;which is correct script code.&lt;/P&gt;&lt;P&gt;&lt;B&gt;Bottom line&lt;/B&gt;: in script, $(variable) will always be expanded to the &lt;I&gt;exact (textual) value&lt;/I&gt; in the variable; make sure that the script is correct if you replace $(variable) with the exact value of the variable yourself.&lt;/P&gt;&lt;P&gt;Hope this clears things up a bit for you.&lt;/P&gt;&lt;P&gt;Martijn ter Schegget&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 18:52:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/LET-SET-date-question/m-p/166504#M504875</guid>
      <dc:creator />
      <dc:date>2009-08-26T18:52:31Z</dc:date>
    </item>
  </channel>
</rss>

