<?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: Using Dates in an expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822839#M473292</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;q:&lt;/P&gt;&lt;P&gt;load &lt;/P&gt;&lt;P&gt;&amp;nbsp; DateField,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(DateField &amp;lt; date(Today(), 'MM/DD/YYYY'),1,0) as Flag;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;&amp;nbsp; date(floor(today() + rand()*100 - rand()*100), 'MM/DD/YYYY') as DateField&lt;/P&gt;&lt;P&gt;autogenerate 10000;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Nov 2014 22:41:00 GMT</pubDate>
    <dc:creator>maxgro</dc:creator>
    <dc:date>2014-11-12T22:41:00Z</dc:date>
    <item>
      <title>Using Dates in an expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822837#M473290</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 am trying to use a date formatted MM/DD/YYYY and compare it to today's date in an expression.&amp;nbsp; I would like to have all dates before the current date flagged and all the dates after the current date to remain unflagged.&amp;nbsp; The expression that is not working for me is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if( DateField &amp;lt; Today(), 1,0) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm just trying to flag all dates before today as 1, all dates after today as 0.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Nov 2014 22:21:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822837#M473290</guid>
      <dc:creator />
      <dc:date>2014-11-12T22:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using Dates in an expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822838#M473291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would simply wrap both sides of that expression with the Num() function to compare apples to apples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If( Num(DateField) &amp;lt; Num(Today()), 1, 0) as DateFlag&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;Oscar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Nov 2014 22:38:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822838#M473291</guid>
      <dc:creator>oscar_ortiz</dc:creator>
      <dc:date>2014-11-12T22:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using Dates in an expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822839#M473292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;q:&lt;/P&gt;&lt;P&gt;load &lt;/P&gt;&lt;P&gt;&amp;nbsp; DateField,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(DateField &amp;lt; date(Today(), 'MM/DD/YYYY'),1,0) as Flag;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;&amp;nbsp; date(floor(today() + rand()*100 - rand()*100), 'MM/DD/YYYY') as DateField&lt;/P&gt;&lt;P&gt;autogenerate 10000;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Nov 2014 22:41:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822839#M473292</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-11-12T22:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using Dates in an expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822840#M473293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;&amp;nbsp; *, &lt;/P&gt;&lt;P&gt;&amp;nbsp; If(Date(Date#(DateField,'DD/MM/YYYY'))&amp;lt;Date(Today()),1,0) as Flag &lt;/P&gt;&lt;P&gt;Inline&lt;/P&gt;&lt;P&gt;[&lt;/P&gt;&lt;P&gt;&amp;nbsp; DateField&lt;/P&gt;&lt;P&gt;&amp;nbsp; 01/01/2014&lt;/P&gt;&lt;P&gt;&amp;nbsp; 14/05/2014&lt;/P&gt;&lt;P&gt;&amp;nbsp; 10/11/2014&lt;/P&gt;&lt;P&gt;&amp;nbsp; 15/12/2014&lt;/P&gt;&lt;P&gt;&amp;nbsp; 01/01/2015&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or Simply use below expression at UI end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;If(Date(Date#(DateField,'DD/MM/YYYY'))&amp;lt;Date(Today()),1,0) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Nov 2014 22:41:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822840#M473293</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2014-11-12T22:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Using Dates in an expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822841#M473294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree that&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14158344134091576" jivemacro_uid="_14158344134091576"&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;if( DateField &amp;lt; Today(), 1,0)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;not working suggests that DateField is Text and not Dual.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your approach&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14158344190593627" jivemacro_uid="_14158344190593627"&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;If(Date(Date#(DateField,'DD/MM/YYYY'))&amp;lt;Date(Today()),1,0)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;should work fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'd like to add that the outer date() functions in this case don't change the value and thus should not influence the comparison, i.e.&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_14158344235342607 jive_text_macro jive_macro_code" jivemacro_uid="_14158344235342607"&gt;
&lt;P&gt;If(Date#(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;DateField&lt;/SPAN&gt;,'DD/MM/YYYY')&amp;lt;Today(),1,0)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;should work as well and can even be abbreviated to&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14158344277703231" jivemacro_uid="_14158344277703231"&gt;
&lt;P&gt;-(Date#(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;DateField&lt;/SPAN&gt;,'DD/MM/YYYY')&amp;lt;Today())&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Nov 2014 23:19:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822841#M473294</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2014-11-12T23:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using Dates in an expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822842#M473295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the well formatted response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Nov 2014 21:26:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822842#M473295</guid>
      <dc:creator />
      <dc:date>2014-11-13T21:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using Dates in an expression</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822843#M473296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're welcome&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Nov 2014 21:44:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Dates-in-an-expression/m-p/822843#M473296</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2014-11-13T21:44:29Z</dc:date>
    </item>
  </channel>
</rss>

