<?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 Assign variable with select statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Assign-variable-with-select-statement/m-p/1234948#M861075</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im having problems with this.&lt;/P&gt;&lt;P&gt;I have this qlikview script which is run on the 15th of every month. This script intends to automatically take the last date of the previous month in the format of 'YYYY-MM-DD'. For example today is 15th January 2017. I will run my script and it will give me a date of 31th December 2016 in the format 2016-12-31. If it is 15th December 2016, I will get 30th November 2016 in the format 2016-11-30. &lt;/P&gt;&lt;P&gt;I want to set the date retrieved as a variable in the format yyyy-mm-dd to be used in another query. &lt;/P&gt;&lt;P&gt;Basically I tried &lt;/P&gt;&lt;PRE class="prettyprint prettyprinted lang-sql"&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;SET&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;@&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;vLastDate &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; DATE_FORMAT&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;select&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; last_day&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;curdate&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;()&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; INTERVAL &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; MONTH&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;),&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'%Y-%m-%d'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I checked the variable values in settings, I get&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;value is &lt;STRONG&gt;DATE_FORMAT(select last_day(curdate() - INTERVAL 1 MONTH), '%Y-%m-%d') &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;but what I want is the last date value itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I am doing this in qlikview. Please help me identify my problem thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
    <dc:creator />
    <dc:date>2020-11-25T16:16:04Z</dc:date>
    <item>
      <title>Assign variable with select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Assign-variable-with-select-statement/m-p/1234948#M861075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im having problems with this.&lt;/P&gt;&lt;P&gt;I have this qlikview script which is run on the 15th of every month. This script intends to automatically take the last date of the previous month in the format of 'YYYY-MM-DD'. For example today is 15th January 2017. I will run my script and it will give me a date of 31th December 2016 in the format 2016-12-31. If it is 15th December 2016, I will get 30th November 2016 in the format 2016-11-30. &lt;/P&gt;&lt;P&gt;I want to set the date retrieved as a variable in the format yyyy-mm-dd to be used in another query. &lt;/P&gt;&lt;P&gt;Basically I tried &lt;/P&gt;&lt;PRE class="prettyprint prettyprinted lang-sql"&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;SET&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;@&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;vLastDate &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; DATE_FORMAT&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;select&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; last_day&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;curdate&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;()&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; INTERVAL &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; MONTH&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;),&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'%Y-%m-%d'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I checked the variable values in settings, I get&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;value is &lt;STRONG&gt;DATE_FORMAT(select last_day(curdate() - INTERVAL 1 MONTH), '%Y-%m-%d') &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;but what I want is the last date value itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I am doing this in qlikview. Please help me identify my problem thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assign-variable-with-select-statement/m-p/1234948#M861075</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Assign variable with select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Assign-variable-with-select-statement/m-p/1234949#M861076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want the date value itself in a variable in QlikView, you would need to use QlikView functions, not whatever you would use in the select statement if you were coding it there instead. Also a LET instead of SET, because LET evaluates the expression, while SET just takes it literally. Maybe this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LET @vLastDate = date(monthstart(today())-1,'YYYY-MM-DD');&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jan 2017 17:34:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assign-variable-with-select-statement/m-p/1234949#M861076</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2017-01-12T17:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Assign variable with select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Assign-variable-with-select-statement/m-p/1234950#M861077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am 100% agree with John. if the variable needs to calculate values based on some expression then use LET or else &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;you can use SET assign hard code value to it. Also, refer the QlikView function(s) at variable declaration/assignment. If you still want to go ahead with SQL compliant functions then load the SQL expression into a table and assign it to a variable using PEEK function.&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: 13px;"&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: 13px;"&gt;Hope this makes sense.&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: 13px;"&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: 13px;"&gt;Regards!&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: 13px;"&gt;Rahul&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jan 2017 12:36:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assign-variable-with-select-statement/m-p/1234950#M861077</guid>
      <dc:creator>rahulpawarb</dc:creator>
      <dc:date>2017-01-13T12:36:04Z</dc:date>
    </item>
  </channel>
</rss>

