<?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 Automate Report Start Date in SQL Using Variable? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404538#M697346</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to automate the starting/cutoff point in my SQL using a reference to a variable created in my script.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In my variables section, I have created a 'Let' variable that generates a date based on the report reload time.&amp;nbsp; I've called this variable vLastQtr.&amp;nbsp; It currently generates a date of 2/1/2012 (February 1, 2012) using the MakeDate function.&amp;nbsp; I have reviewed the variable and am satisfied that it generates the correct date. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. In my SQL query, I am pulling data where the date &amp;gt;= '2/1/2012'.&amp;nbsp; In place of the '2/1/2012', I tried substituting $(vLastQtr), thinking that it would compare against the 2/1/2012 date generated by that variable.&amp;nbsp; The script errors out with a message of, "inconsistent datatypes: expected DATE got NUMBER."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to substitute a variable in place of the date in SQL?&amp;nbsp; If so, how do I correct the data type consistency, so the SQL will recognize it properly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Mar 2013 18:27:52 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-03-28T18:27:52Z</dc:date>
    <item>
      <title>Automate Report Start Date in SQL Using Variable?</title>
      <link>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404538#M697346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to automate the starting/cutoff point in my SQL using a reference to a variable created in my script.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In my variables section, I have created a 'Let' variable that generates a date based on the report reload time.&amp;nbsp; I've called this variable vLastQtr.&amp;nbsp; It currently generates a date of 2/1/2012 (February 1, 2012) using the MakeDate function.&amp;nbsp; I have reviewed the variable and am satisfied that it generates the correct date. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. In my SQL query, I am pulling data where the date &amp;gt;= '2/1/2012'.&amp;nbsp; In place of the '2/1/2012', I tried substituting $(vLastQtr), thinking that it would compare against the 2/1/2012 date generated by that variable.&amp;nbsp; The script errors out with a message of, "inconsistent datatypes: expected DATE got NUMBER."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to substitute a variable in place of the date in SQL?&amp;nbsp; If so, how do I correct the data type consistency, so the SQL will recognize it properly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 18:27:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404538#M697346</guid>
      <dc:creator />
      <dc:date>2013-03-28T18:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Automate Report Start Date in SQL Using Variable?</title>
      <link>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404539#M697347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Try to assign the variable in this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let vDate = '"'&amp;amp;Text(Date(MakeDate(2013,02,01),'DD-MMM-YYYY'))&amp;amp;'"';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sql Select * from abc where date &amp;gt;= '$(vDate)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sql Select * from abc where date &amp;gt;= $(vDate);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kaushik Solanki&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 18:32:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404539#M697347</guid>
      <dc:creator>kaushiknsolanki</dc:creator>
      <dc:date>2013-03-28T18:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Automate Report Start Date in SQL Using Variable?</title>
      <link>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404540#M697348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Kaushik.&amp;nbsp; I tried your solution, but experienced the following issues: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use single quotes ( ' ') around the '$(vDate)' in my SQL, it fetches zero records.&amp;nbsp; The syntax check gives the appearance that it does not recognize it as a variable (not italicized or in gray like other variables.&amp;nbsp; Example: &lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;$(vLastQtrDate6). &lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I &lt;SPAN style="text-decoration: underline;"&gt;do not &lt;/SPAN&gt;use single quotes $(vDate) for my date criteria, the script returns an error that an expression is missing.&amp;nbsp; When I scroll to the date portion of the where clause in the SQL statement, the date is blank. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any other thoughts?&amp;nbsp; I suspect that using a variable will work.&amp;nbsp; I just don't have the right date format.&amp;nbsp; I would send a QV sample, but it would be time-consuming to recreate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I perhaps use single quotes in place of either of the double quotes in the let vDate formula?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 19:59:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404540#M697348</guid>
      <dc:creator />
      <dc:date>2013-03-28T19:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Automate Report Start Date in SQL Using Variable?</title>
      <link>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404541#M697349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When you use with Quotes it fecthed 0 record. Are you sure you have the data before the date specified in the variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kaushik Solanki&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Mar 2013 05:48:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Automate-Report-Start-Date-in-SQL-Using-Variable/m-p/404541#M697349</guid>
      <dc:creator>kaushiknsolanki</dc:creator>
      <dc:date>2013-03-29T05:48:09Z</dc:date>
    </item>
  </channel>
</rss>

