<?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: Save Last and before last dates in Date field as Script variables and using them with in the script in where condition.. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Save-Last-and-before-last-dates-in-Date-field-as-Script/m-p/440659#M164246</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, assuming your date field is named Date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vLastDate = peek('Date');&lt;/P&gt;&lt;P&gt;LET vBeforeLastDate = peek('Date',-2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the max and second highest try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;load max(Date) as Max1, max(Date,2) as Max2&lt;/P&gt;&lt;P&gt;Resident ...table_with_dates...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMax1 = peek('Max1');&lt;/P&gt;&lt;P&gt;LET vMax2 = peek('Max2');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop Table Temp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the variables like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load * from &lt;EM&gt;...sometable...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;where OrderDate &amp;lt;=&lt;STRONG&gt; $(vLastDate)&lt;/STRONG&gt; ;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 May 2013 18:22:28 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2013-05-08T18:22:28Z</dc:date>
    <item>
      <title>Save Last and before last dates in Date field as Script variables and using them with in the script in where condition..</title>
      <link>https://community.qlik.com/t5/QlikView/Save-Last-and-before-last-dates-in-Date-field-as-Script/m-p/440658#M164245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can I save Last and before last dates in a date field as script variables and use them in where condition while joinning?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 18:17:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Save-Last-and-before-last-dates-in-Date-field-as-Script/m-p/440658#M164245</guid>
      <dc:creator />
      <dc:date>2013-05-08T18:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Save Last and before last dates in Date field as Script variables and using them with in the script in where condition..</title>
      <link>https://community.qlik.com/t5/QlikView/Save-Last-and-before-last-dates-in-Date-field-as-Script/m-p/440659#M164246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, assuming your date field is named Date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vLastDate = peek('Date');&lt;/P&gt;&lt;P&gt;LET vBeforeLastDate = peek('Date',-2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the max and second highest try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;load max(Date) as Max1, max(Date,2) as Max2&lt;/P&gt;&lt;P&gt;Resident ...table_with_dates...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMax1 = peek('Max1');&lt;/P&gt;&lt;P&gt;LET vMax2 = peek('Max2');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop Table Temp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the variables like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load * from &lt;EM&gt;...sometable...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;where OrderDate &amp;lt;=&lt;STRONG&gt; $(vLastDate)&lt;/STRONG&gt; ;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 18:22:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Save-Last-and-before-last-dates-in-Date-field-as-Script/m-p/440659#M164246</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-05-08T18:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Save Last and before last dates in Date field as Script variables and using them with in the script in where condition..</title>
      <link>https://community.qlik.com/t5/QlikView/Save-Last-and-before-last-dates-in-Date-field-as-Script/m-p/440660#M164247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 18:40:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Save-Last-and-before-last-dates-in-Date-field-as-Script/m-p/440660#M164247</guid>
      <dc:creator />
      <dc:date>2013-05-08T18:40:55Z</dc:date>
    </item>
  </channel>
</rss>

