<?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 Evaluating a date variable in a Macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Evaluating-a-date-variable-in-a-Macro/m-p/179592#M46390</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Folks, I've been fighting with this one for a while and I'm struggling.&lt;/P&gt;&lt;P&gt;Firstly, I have a master calendar table with joins to various fact tables that are working well and as expected. The calendar dates are stored as DD/MM/YYYY and they are as dates (rather than string representations of dates)&lt;/P&gt;&lt;P&gt;Secondly, I have 2 calendar objects, to allow users to select a start date and end date. These dates are stored as variables in QV's native date form eg (&lt;B&gt;39836&lt;/B&gt; for 23 Jan 2009)&lt;/P&gt;&lt;P&gt;Now I am trying to use a macro to make a selection in my calendar table whenever either of the calendar objects changes:&lt;/P&gt;&lt;P&gt;[CODE]&lt;/P&gt;&lt;P&gt;SUB UpdateDates&lt;/P&gt;&lt;P&gt;DIM theStartDate&lt;BR /&gt; theStartDate = ActiveDocument.Variables("dateStart").GetContent().string&lt;BR /&gt; 'theStartDate = FormatDateTime(Now(),2) 'This wont even work!&lt;/P&gt;&lt;P&gt;ActiveDocument.GetField("[Calendar Date]").Select&lt;BR /&gt; ActiveDocument.Evaluate(theStartDate)&lt;/P&gt;&lt;P&gt;END SUB&lt;/P&gt;&lt;P&gt;[/CODE]&lt;/P&gt;&lt;P&gt;Obviously in this example, there is a missmatch between the two dates I am evaluating (39836 does not match 23/01/2009) but I have tried this code even with a date. The only thing that seems to work is if I do &lt;PRE&gt; ActiveDocument.Evaluate(today())&lt;/PRE&gt;&lt;/P&gt;&lt;P&gt;I hope someone can help.&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 13 Mar 2010 12:32:46 GMT</pubDate>
    <dc:creator>gsbeaton</dc:creator>
    <dc:date>2010-03-13T12:32:46Z</dc:date>
    <item>
      <title>Evaluating a date variable in a Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Evaluating-a-date-variable-in-a-Macro/m-p/179592#M46390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Folks, I've been fighting with this one for a while and I'm struggling.&lt;/P&gt;&lt;P&gt;Firstly, I have a master calendar table with joins to various fact tables that are working well and as expected. The calendar dates are stored as DD/MM/YYYY and they are as dates (rather than string representations of dates)&lt;/P&gt;&lt;P&gt;Secondly, I have 2 calendar objects, to allow users to select a start date and end date. These dates are stored as variables in QV's native date form eg (&lt;B&gt;39836&lt;/B&gt; for 23 Jan 2009)&lt;/P&gt;&lt;P&gt;Now I am trying to use a macro to make a selection in my calendar table whenever either of the calendar objects changes:&lt;/P&gt;&lt;P&gt;[CODE]&lt;/P&gt;&lt;P&gt;SUB UpdateDates&lt;/P&gt;&lt;P&gt;DIM theStartDate&lt;BR /&gt; theStartDate = ActiveDocument.Variables("dateStart").GetContent().string&lt;BR /&gt; 'theStartDate = FormatDateTime(Now(),2) 'This wont even work!&lt;/P&gt;&lt;P&gt;ActiveDocument.GetField("[Calendar Date]").Select&lt;BR /&gt; ActiveDocument.Evaluate(theStartDate)&lt;/P&gt;&lt;P&gt;END SUB&lt;/P&gt;&lt;P&gt;[/CODE]&lt;/P&gt;&lt;P&gt;Obviously in this example, there is a missmatch between the two dates I am evaluating (39836 does not match 23/01/2009) but I have tried this code even with a date. The only thing that seems to work is if I do &lt;PRE&gt; ActiveDocument.Evaluate(today())&lt;/PRE&gt;&lt;/P&gt;&lt;P&gt;I hope someone can help.&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Mar 2010 12:32:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Evaluating-a-date-variable-in-a-Macro/m-p/179592#M46390</guid>
      <dc:creator>gsbeaton</dc:creator>
      <dc:date>2010-03-13T12:32:46Z</dc:date>
    </item>
    <item>
      <title>Evaluating a date variable in a Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Evaluating-a-date-variable-in-a-Macro/m-p/179593#M46391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;George,&lt;/P&gt;&lt;P&gt;A couple of comments:&lt;/P&gt;&lt;P&gt;1. If you are on ver. 9.00, you can apply selection on a field using Actions, in a much simpler way.&lt;/P&gt;&lt;P&gt;2. If you have to use macros, - I suppose there is a way to format date in VBScript, only I don't know it, so I can suggest a QlikView solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Define another variable that holds a formatted dateStart:&lt;/P&gt;&lt;P&gt;SET v_FormattedDateStart = '=date(dateStart, 'DD/MM/YYYY')';&lt;/P&gt;&lt;P&gt;Then, in your macro, simply get the text and use it for Selection:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&amp;lt;pre&amp;gt;&lt;BR /&gt;SUB UpdateDates theStartDate = ActiveDocument.Variables("v_FormattedDateStart").GetContent().string&lt;BR /&gt; ActiveDocument.GetField("[Calendar Date]").Select theStartDate&lt;BR /&gt;END SUB&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Mar 2010 21:35:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Evaluating-a-date-variable-in-a-Macro/m-p/179593#M46391</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2010-03-13T21:35:37Z</dc:date>
    </item>
  </channel>
</rss>

