<?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 Dates from strings using Date#() and handling invalid dates in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933723#M1219077</link>
    <description>&lt;P&gt;Background, there are trash dates stored as strings in the source data.&amp;nbsp; We're converting those values in the script using Date(Date#(datestring,'YYYYMMDD')). This morning&amp;nbsp; found an oddity.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;Feb. 31st and&amp;nbsp; Sep. 31st would never be a valid date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=DATE(DATE#(20220231,'YYYYMMDD'))&amp;nbsp; evaluates to 03/03/2022&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=DATE(DATE#(20220931,'YYYYMMDD'))&amp;nbsp; evaluates to 10/01/2022&lt;/P&gt;
&lt;P&gt;This makes sense considering the&amp;nbsp;&lt;SPAN&gt;number of days passed since December 30, 1899 and the order of the calculations.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;NUM(DATE#(20220231,'YYYYMMDD') evaluates to 44623&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;DATE(01/01/1900 + 44623) evaluates to 03/03/2022&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;It just seems like there would be some check in the Date#() function for a valid date.&amp;nbsp; Further testing shows that it may be actually be doing a check, but for days between 1 and 31 in any given month.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;=DATE#(20220200,'YYYYMMDD') and =DATE#(20220232,'YYYYMMDD') appear not to evaluate.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this intentional and working as designed?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone have a way to account for this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally I'd want these examples to not evaluate to a valid date is the string is not a valid date just as YYYYMM00 and YYYYMM32 do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&lt;LI-PRODUCT title="QlikView" id="qlikView"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 May 2022 16:05:41 GMT</pubDate>
    <dc:creator>Jacob_Poole</dc:creator>
    <dc:date>2022-05-20T16:05:41Z</dc:date>
    <item>
      <title>Dates from strings using Date#() and handling invalid dates</title>
      <link>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933723#M1219077</link>
      <description>&lt;P&gt;Background, there are trash dates stored as strings in the source data.&amp;nbsp; We're converting those values in the script using Date(Date#(datestring,'YYYYMMDD')). This morning&amp;nbsp; found an oddity.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;Feb. 31st and&amp;nbsp; Sep. 31st would never be a valid date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=DATE(DATE#(20220231,'YYYYMMDD'))&amp;nbsp; evaluates to 03/03/2022&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=DATE(DATE#(20220931,'YYYYMMDD'))&amp;nbsp; evaluates to 10/01/2022&lt;/P&gt;
&lt;P&gt;This makes sense considering the&amp;nbsp;&lt;SPAN&gt;number of days passed since December 30, 1899 and the order of the calculations.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;NUM(DATE#(20220231,'YYYYMMDD') evaluates to 44623&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;DATE(01/01/1900 + 44623) evaluates to 03/03/2022&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;It just seems like there would be some check in the Date#() function for a valid date.&amp;nbsp; Further testing shows that it may be actually be doing a check, but for days between 1 and 31 in any given month.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;=DATE#(20220200,'YYYYMMDD') and =DATE#(20220232,'YYYYMMDD') appear not to evaluate.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this intentional and working as designed?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone have a way to account for this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally I'd want these examples to not evaluate to a valid date is the string is not a valid date just as YYYYMM00 and YYYYMM32 do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&lt;LI-PRODUCT title="QlikView" id="qlikView"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 16:05:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933723#M1219077</guid>
      <dc:creator>Jacob_Poole</dc:creator>
      <dc:date>2022-05-20T16:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dates from strings using Date#() and handling invalid dates</title>
      <link>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933761#M1219078</link>
      <description>&lt;P&gt;maybe you could check for validity e.g. like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;If(Date(Date#(datestring,'YYYYMMDD'),'YYYYMMDD')=datestring,Date(Date#(datestring,'YYYYMMDD'))) as CorrectDate&lt;/LI-CODE&gt;
&lt;P&gt;hope this helps&lt;/P&gt;
&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 18:21:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933761#M1219078</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2022-05-20T18:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dates from strings using Date#() and handling invalid dates</title>
      <link>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933769#M1219079</link>
      <description>&lt;P&gt;I&amp;nbsp; added the text() function, and this idea seems to be working.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EX:&lt;/P&gt;
&lt;P&gt;=If(TEXT(Date(Date#(20220228,'YYYYMMDD'),'YYYYMMDD'))='20220228',Date(Date#(20220228,'YYYYMMDD'))) - evaluates&lt;/P&gt;
&lt;P&gt;=If(TEXT(Date(Date#(20220231,'YYYYMMDD'),'YYYYMMDD'))='20220231',Date(Date#(20220231,'YYYYMMDD'))) - does not evaluate&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks Marco&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 18:57:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933769#M1219079</guid>
      <dc:creator>Jacob_Poole</dc:creator>
      <dc:date>2022-05-20T18:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dates from strings using Date#() and handling invalid dates</title>
      <link>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933780#M1219080</link>
      <description>&lt;P&gt;glad it worked.&lt;/P&gt;
&lt;P&gt;please close your thread by accepting a solution if your question is answered&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 19:40:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dates-from-strings-using-Date-and-handling-invalid-dates/m-p/1933780#M1219080</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2022-05-20T19:40:45Z</dc:date>
    </item>
  </channel>
</rss>

