<?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 Passing single quotes to a variable - used in SQL where statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Passing-single-quotes-to-a-variable-used-in-SQL-where-statement/m-p/431141#M160739</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Problem: I need to store a date in a variable used in SQL Where statement but the single quotes around the date do not come through.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable that pulls a date used as the earliest date I want to pull data for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13679022767182257" jivemacro_uid="_13679022767182257"&gt;&lt;P&gt;tStartDate:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(DataStartDt) as DataStartDt&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;Calendar.qvd&lt;/P&gt;&lt;P&gt;(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vStartDate = Peek('DataStartDt');&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in this case vStartDate = 40544&amp;nbsp;&amp;nbsp;&amp;nbsp; (translating to the date&amp;nbsp;&amp;nbsp; 1/1/2011)&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The date is then used in the vIncrementalExpression which holds the Where in my SQL statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1367902276717422" jivemacro_uid="_1367902276717422"&gt;&lt;P&gt;LET vIncrementalExpression = 'WHERE dataDate &amp;gt;=' &amp;amp; date($(vStartDate), 'MM/DD/YYYY'); &lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;Used in SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13679022767177460" jivemacro_uid="_13679022767177460"&gt;&lt;P&gt;TableName:&lt;/P&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;FROM testData&lt;/P&gt;&lt;P&gt;$(vIncrementalExpression)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;----------------------------------&lt;/P&gt;&lt;P&gt;This translates to this in SQL&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13679022767164407" jivemacro_uid="_13679022767164407"&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;From testData&lt;SPAN style="font-size: 10pt;"&gt; WHERE dataDate &amp;gt;= 01/01/2011&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTICE the missing single quotes around the date.&amp;nbsp; This needs to be&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1367902276715197" jivemacro_uid="_1367902276715197"&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;From testData&lt;SPAN style="font-size: 10pt;"&gt; WHERE dataDate &amp;gt;= '01/01/2011'&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 May 2013 04:50:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-05-07T04:50:35Z</dc:date>
    <item>
      <title>Passing single quotes to a variable - used in SQL where statement</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-single-quotes-to-a-variable-used-in-SQL-where-statement/m-p/431141#M160739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Problem: I need to store a date in a variable used in SQL Where statement but the single quotes around the date do not come through.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable that pulls a date used as the earliest date I want to pull data for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13679022767182257" jivemacro_uid="_13679022767182257"&gt;&lt;P&gt;tStartDate:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(DataStartDt) as DataStartDt&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;Calendar.qvd&lt;/P&gt;&lt;P&gt;(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vStartDate = Peek('DataStartDt');&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in this case vStartDate = 40544&amp;nbsp;&amp;nbsp;&amp;nbsp; (translating to the date&amp;nbsp;&amp;nbsp; 1/1/2011)&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The date is then used in the vIncrementalExpression which holds the Where in my SQL statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1367902276717422" jivemacro_uid="_1367902276717422"&gt;&lt;P&gt;LET vIncrementalExpression = 'WHERE dataDate &amp;gt;=' &amp;amp; date($(vStartDate), 'MM/DD/YYYY'); &lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;Used in SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13679022767177460" jivemacro_uid="_13679022767177460"&gt;&lt;P&gt;TableName:&lt;/P&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;FROM testData&lt;/P&gt;&lt;P&gt;$(vIncrementalExpression)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;----------------------------------&lt;/P&gt;&lt;P&gt;This translates to this in SQL&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13679022767164407" jivemacro_uid="_13679022767164407"&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;From testData&lt;SPAN style="font-size: 10pt;"&gt; WHERE dataDate &amp;gt;= 01/01/2011&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTICE the missing single quotes around the date.&amp;nbsp; This needs to be&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1367902276715197" jivemacro_uid="_1367902276715197"&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;From testData&lt;SPAN style="font-size: 10pt;"&gt; WHERE dataDate &amp;gt;= '01/01/2011'&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 May 2013 04:50:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-single-quotes-to-a-variable-used-in-SQL-where-statement/m-p/431141#M160739</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-07T04:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Passing single quotes to a variable - used in SQL where statement</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-single-quotes-to-a-variable-used-in-SQL-where-statement/m-p/431142#M160740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi darrin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe this one can do your job. Let try&lt;/P&gt;&lt;P&gt;LET vIncrementalExpression = 'WHERE dataDate &amp;gt;=' &amp;amp; Chr(39) &amp;amp; date($(vStartDate), 'MM/DD/YYYY') &amp;amp; Chr(39);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sokkorn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 May 2013 04:57:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-single-quotes-to-a-variable-used-in-SQL-where-statement/m-p/431142#M160740</guid>
      <dc:creator>Sokkorn</dc:creator>
      <dc:date>2013-05-07T04:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Passing single quotes to a variable - used in SQL where statement</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-single-quotes-to-a-variable-used-in-SQL-where-statement/m-p/431143#M160741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sokkorn,&lt;/P&gt;&lt;P&gt;Thank you very much.&amp;nbsp; I can't believe I didn't think of that and thought it would be something very simple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the quick response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 May 2013 05:29:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-single-quotes-to-a-variable-used-in-SQL-where-statement/m-p/431143#M160741</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-07T05:29:39Z</dc:date>
    </item>
  </channel>
</rss>

