<?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 How to select Datetime field values in a macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234388#M85816</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK Solved it now. I assumed that date comparisons would happen by evaluating a date value, so I was trying to convert my string into a date to do the selection. This is wrong. Using .Select does a match on the actual characters in the field, so formatting matters *alot*. My solution was to open up document properties, set the formatting of this field to be YYY-MM-DD and then this line started to work:&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select "2006-02-28"&lt;/P&gt;&lt;P&gt;Thanks to &lt;STRONG&gt;&lt;A href="http://community.qlik.com/members/jsn/default.aspx"&gt;Johannes Sundén&lt;/A&gt; for your suggestions.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Oct 2010 11:36:03 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-10-12T11:36:03Z</dc:date>
    <item>
      <title>How to select Datetime field values in a macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234385#M85813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm writing a macro that selects values for the current date when the document is first opened. For whatever reason, some of the values in the date field are displayed as *only* date, for example 5/7/2010 and others have a datetime representation like 9/10/2010 12:00:00 AM.&lt;/P&gt;&lt;P&gt;In the macro I'm writing the following line works just fine for the 'pure' date values:&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select CDate("2010-07-05")&lt;/P&gt;&lt;P&gt;but for the datetime values the following does not work&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select CDate("2010-10-09 12:00:00 AM")&lt;/P&gt;&lt;P&gt;Why?&lt;/P&gt;&lt;P&gt;I've tried many combinations and possible string representations to no avail&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;BR /&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 05:30:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234385#M85813</guid>
      <dc:creator />
      <dc:date>2010-10-12T05:30:59Z</dc:date>
    </item>
    <item>
      <title>How to select Datetime field values in a macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234386#M85814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try skipping the CDate() function and just do .Select "Datevalue"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 07:01:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234386#M85814</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-12T07:01:51Z</dc:date>
    </item>
    <item>
      <title>How to select Datetime field values in a macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234387#M85815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These are all the attempts I've made so far. None of these have worked for selecting Feb 28th, 2006 in the Date1field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select "2006-02-28 12:00:00 AM"&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select #2006-02-28 12:00:00 AM#&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select CDate("2006-02-28 12:00:00 AM")&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select ActiveDocument.Evaluate("date('2006-02-28','YYYY-MM-DD')")&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select ActiveDocument.Evaluate("date('2006-02-28 12:00:00 AM','YYYY-MM-DD')")&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select "2006-02-28 *"&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 11:24:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234387#M85815</guid>
      <dc:creator />
      <dc:date>2010-10-12T11:24:32Z</dc:date>
    </item>
    <item>
      <title>How to select Datetime field values in a macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234388#M85816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK Solved it now. I assumed that date comparisons would happen by evaluating a date value, so I was trying to convert my string into a date to do the selection. This is wrong. Using .Select does a match on the actual characters in the field, so formatting matters *alot*. My solution was to open up document properties, set the formatting of this field to be YYY-MM-DD and then this line started to work:&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("Date").Select "2006-02-28"&lt;/P&gt;&lt;P&gt;Thanks to &lt;STRONG&gt;&lt;A href="http://community.qlik.com/members/jsn/default.aspx"&gt;Johannes Sundén&lt;/A&gt; for your suggestions.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 11:36:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-select-Datetime-field-values-in-a-macro/m-p/234388#M85816</guid>
      <dc:creator />
      <dc:date>2010-10-12T11:36:03Z</dc:date>
    </item>
  </channel>
</rss>

