<?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 Re: SQL Select Date Against A Variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SQL-Select-Date-Against-A-Variable/m-p/1039089#M927418</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Try WHERE MyDate &amp;gt;= '$(varSelectDate)'&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;Or try &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em;"&gt;WHERE MyDate &amp;gt;=$(&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;varMinDate&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Apr 2016 15:52:02 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2016-04-01T15:52:02Z</dc:date>
    <item>
      <title>SQL Select Date Against A Variable</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Select-Date-Against-A-Variable/m-p/1039087#M927416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having trouble loading data from an SQL server table on a datetime field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First I tried a hard coded selection against a literal date.&amp;nbsp; It worked.&lt;/P&gt;&lt;P&gt;See below.&lt;/P&gt;&lt;P&gt;/ ===============================&lt;BR /&gt;// Basic Load With hard Coded Date&lt;BR /&gt;// ===============================&lt;BR /&gt;LOAD&lt;BR /&gt;MyField1,&lt;BR /&gt;MyField2,&lt;/P&gt;&lt;P&gt;MyDate;&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM MyTable&lt;BR /&gt;WHERE MyDate &amp;gt;= '01/04/2015';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I tried it as a variable that is calculated to set the date to 12 months ago.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// ===================================================&lt;BR /&gt;// Code Selection To Last 12 Months As Calculated Date&lt;BR /&gt;// ===================================================&lt;BR /&gt;Let varTodaysDate = Today();&lt;/P&gt;&lt;P&gt;//&lt;BR /&gt;// Start Range Date&lt;BR /&gt;Let varDate1 = AddMonths(varTodaysDate,-12);&lt;BR /&gt;Let varMinDate = Num(varDate1);&lt;BR /&gt;Let varSelectDate = Date(varMinDate,'DD/MM/YYYY');&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;MyField1,&lt;BR /&gt;MyField2,&lt;/P&gt;&lt;P&gt;MyDate;&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM MyTable&lt;BR /&gt;WHERE MyDate &amp;gt;=$(varSelectDate);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This second version does not work correctly.&amp;nbsp; It loads way to many records.&lt;/P&gt;&lt;P&gt;Somehow I have a format problem on the variable varSelectDate even though when I check it in debug it has a value of '01/04/2015'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions appreciated.&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/SQL-Select-Date-Against-A-Variable/m-p/1039087#M927416</guid>
      <dc:creator>rebelfox</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Select Date Against A Variable</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Select-Date-Against-A-Variable/m-p/1039088#M927417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you should embed the variable expansion in single quotes to prevent a numeric evaluation of your date format as divisions:&lt;/P&gt;&lt;P&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;WHERE MyDate &amp;gt;= '$(varSelectDate)';&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Apr 2016 15:51:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-Select-Date-Against-A-Variable/m-p/1039088#M927417</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-04-01T15:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Select Date Against A Variable</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Select-Date-Against-A-Variable/m-p/1039089#M927418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Try WHERE MyDate &amp;gt;= '$(varSelectDate)'&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;Or try &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em;"&gt;WHERE MyDate &amp;gt;=$(&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;varMinDate&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Apr 2016 15:52:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-Select-Date-Against-A-Variable/m-p/1039089#M927418</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2016-04-01T15:52:02Z</dc:date>
    </item>
  </channel>
</rss>

