<?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: Date comparison is not correct in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Date-comparison-is-not-correct/m-p/1769760#M59536</link>
    <description>&lt;P&gt;I think you have some issues with the parenthesis grouping the logical statements. I removed a parenthesis from your expression and it should now work as intended. (I also removed some Date() formatting as they are not necessary in your expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;if( len(trim("TRADE DATE (P0561)"))=0 and len(trim("MATURITY DATE (P0288)"))=0,'exist',
 if( date#("TRADE DATE (P0561)",'yyyyMMdd')&amp;gt;=yearSTART(Date#("ACCTG DATE (P0045)",'yyyyMMdd')) and Date#("MATURITY DATE (P0288)",'yyyyMMdd')&amp;gt; Date#("ACCTG DATE (P0045)",'yyyyMMdd'),'new',
  if( Date#("MATURITY DATE (P0288)",'yyyyMMdd')&amp;lt;(yearSTART(Date#("ACCTG DATE (P0045)",'yyyyMMdd')) ),'matured','exist'))) as status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This expression return a mix of 'matured' and 'exist'.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Dec 2020 09:01:39 GMT</pubDate>
    <dc:creator>Vegar</dc:creator>
    <dc:date>2020-12-21T09:01:39Z</dc:date>
    <item>
      <title>Date comparison is not correct</title>
      <link>https://community.qlik.com/t5/App-Development/Date-comparison-is-not-correct/m-p/1769710#M59519</link>
      <description>&lt;P&gt;I have below script that try to determine whether a Trade num is exist, matured, new.&lt;/P&gt;&lt;P&gt;The logic is :&lt;/P&gt;&lt;P&gt;(1) if the trade date is &amp;gt; accounting date , it is new&lt;/P&gt;&lt;P&gt;(2) if the maturity date is &amp;lt; 1st Jan 2020 (year start of&amp;nbsp; accounting date), it is mature&lt;/P&gt;&lt;P&gt;(3) if the maturity is &amp;gt; accounting date, it is exist.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(4) If there is no date reference, treat the deal is exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Script is as below:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;if(len(trim("TRADE DATE (P0561)"))=0 and len(trim("MATURITY DATE (P0288)"))=0,'exist', &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;if(Date(date#("TRADE DATE (P0561)",'yyyyMMdd'),'YYYYMMDD')&amp;gt;=(yearSTART(Date(Date#("ACCTG DATE (P0045)",'yyyyMMdd'),'YYYYMMDD')) &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;and Date(Date#("MATURITY DATE (P0288)",'yyyyMMdd'),'YYYYMMDD')&amp;gt; Date(Date#("ACCTG DATE (P0045)",'yyyyMMdd'),'YYYYMMDD')),'new', &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;if(Date(Date#("MATURITY DATE (P0288)",'yyyyMMdd'),'YYYYMMDD')&amp;lt;(yearSTART(Date(Date#("ACCTG DATE (P0045)",'yyyyMMdd'),'YYYYMMDD')) ),'matured','exist'))) as status,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I don't know why the result for below is new.&amp;nbsp; I expect the correct type is exist .&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Hope I can get some guidance.&amp;nbsp; Many thanks.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;GLOBAL TRADE NUM (P0221)&lt;/TD&gt;&lt;TD&gt;TRADE DATE (P0561)&lt;/TD&gt;&lt;TD&gt;MATURITY DATE (P0288)&lt;/TD&gt;&lt;TD&gt;ACCTG DATE (P0045)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1000328H&lt;/TD&gt;&lt;TD&gt;20120419&lt;/TD&gt;&lt;TD&gt;20200423&lt;/TD&gt;&lt;TD&gt;20201130&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1000328H&lt;/TD&gt;&lt;TD&gt;20120419&lt;/TD&gt;&lt;TD&gt;20200423&lt;/TD&gt;&lt;TD&gt;20201130&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001853H&lt;/TD&gt;&lt;TD&gt;20120423&lt;/TD&gt;&lt;TD&gt;20200425&lt;/TD&gt;&lt;TD&gt;20201130&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001853H&lt;/TD&gt;&lt;TD&gt;20120423&lt;/TD&gt;&lt;TD&gt;20200425&lt;/TD&gt;&lt;TD&gt;20201130&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1004253H&lt;/TD&gt;&lt;TD&gt;20120427&lt;/TD&gt;&lt;TD&gt;20190501&lt;/TD&gt;&lt;TD&gt;20201130&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1004291H&lt;/TD&gt;&lt;TD&gt;20120427&lt;/TD&gt;&lt;TD&gt;20191113&lt;/TD&gt;&lt;TD&gt;20201130&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 20 Dec 2021 21:08:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Date-comparison-is-not-correct/m-p/1769710#M59519</guid>
      <dc:creator>43918084</dc:creator>
      <dc:date>2021-12-20T21:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Date comparison is not correct</title>
      <link>https://community.qlik.com/t5/App-Development/Date-comparison-is-not-correct/m-p/1769760#M59536</link>
      <description>&lt;P&gt;I think you have some issues with the parenthesis grouping the logical statements. I removed a parenthesis from your expression and it should now work as intended. (I also removed some Date() formatting as they are not necessary in your expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;if( len(trim("TRADE DATE (P0561)"))=0 and len(trim("MATURITY DATE (P0288)"))=0,'exist',
 if( date#("TRADE DATE (P0561)",'yyyyMMdd')&amp;gt;=yearSTART(Date#("ACCTG DATE (P0045)",'yyyyMMdd')) and Date#("MATURITY DATE (P0288)",'yyyyMMdd')&amp;gt; Date#("ACCTG DATE (P0045)",'yyyyMMdd'),'new',
  if( Date#("MATURITY DATE (P0288)",'yyyyMMdd')&amp;lt;(yearSTART(Date#("ACCTG DATE (P0045)",'yyyyMMdd')) ),'matured','exist'))) as status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This expression return a mix of 'matured' and 'exist'.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 09:01:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Date-comparison-is-not-correct/m-p/1769760#M59536</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2020-12-21T09:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Date comparison is not correct</title>
      <link>https://community.qlik.com/t5/App-Development/Date-comparison-is-not-correct/m-p/1769775#M59538</link>
      <description>&lt;P&gt;Thank you very much Vegar for solving my problem.&amp;nbsp; I really appreciate it.&lt;/P&gt;&lt;P&gt;WIshing you a Merry Xmas ahead &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 10:22:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Date-comparison-is-not-correct/m-p/1769775#M59538</guid>
      <dc:creator>43918084</dc:creator>
      <dc:date>2020-12-21T10:22:38Z</dc:date>
    </item>
  </channel>
</rss>

