<?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 Function won't strip time off of date in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Function-won-t-strip-time-off-of-date/m-p/60008#M3979</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've created a function in my Sense load script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;Set DateFix =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;If($1 = 4, makedate(SubField(Replace($2, '&amp;nbsp; ', ' '), ' ', 3), Match(Left($2, 3), $(mo)), SubField(Replace($2, '&amp;nbsp; ', ' '), ' ', 2)),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If($1 = 5, Date(SubField($2, ' ', 1)),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If($1 = 7, Date(Floor(Timestamp#($2,'YYYY-MM-DD hh:mm:ss tt')), 'M/D/YYYY'),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $2)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It reformats dates that come in different formats from different files. I call it in the load:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(DateFix(ORGID, VisitStartDate)) as VisitStartDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;Resident aVisit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #ff0000;"&gt;My problem:&lt;/STRONG&gt; The second If statement (where $1 = 5) does not remove the time, no matter what!&amp;nbsp; Dates in this file look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;5/10/2012 12:00:00 AM&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000;"&gt;When I use the same SubField function in the Load statement directly, it works. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(DateFix(ORGID, VisitStartDate)) as VisitStartDate,&amp;nbsp; &lt;SPAN style="color: #808080;"&gt;//Does not strip time&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000; font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(SubField(VisitStartDate, ' ', 1)) as VisDate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080;"&gt;//Successfully strips time&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;Resident aVisit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px;"&gt;Once loaded, VisDate is a date, while VisitStartDate is a timestamp:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/196925_Capture.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;So I'm mystified as to why the same function works in the load script but not in my function, called in the load script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Mar 2018 20:16:15 GMT</pubDate>
    <dc:creator>Lauri</dc:creator>
    <dc:date>2018-03-20T20:16:15Z</dc:date>
    <item>
      <title>Function won't strip time off of date</title>
      <link>https://community.qlik.com/t5/App-Development/Function-won-t-strip-time-off-of-date/m-p/60008#M3979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've created a function in my Sense load script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;Set DateFix =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;If($1 = 4, makedate(SubField(Replace($2, '&amp;nbsp; ', ' '), ' ', 3), Match(Left($2, 3), $(mo)), SubField(Replace($2, '&amp;nbsp; ', ' '), ' ', 2)),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If($1 = 5, Date(SubField($2, ' ', 1)),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If($1 = 7, Date(Floor(Timestamp#($2,'YYYY-MM-DD hh:mm:ss tt')), 'M/D/YYYY'),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $2)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It reformats dates that come in different formats from different files. I call it in the load:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(DateFix(ORGID, VisitStartDate)) as VisitStartDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;Resident aVisit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #ff0000;"&gt;My problem:&lt;/STRONG&gt; The second If statement (where $1 = 5) does not remove the time, no matter what!&amp;nbsp; Dates in this file look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;5/10/2012 12:00:00 AM&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000;"&gt;When I use the same SubField function in the Load statement directly, it works. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(DateFix(ORGID, VisitStartDate)) as VisitStartDate,&amp;nbsp; &lt;SPAN style="color: #808080;"&gt;//Does not strip time&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000; font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(SubField(VisitStartDate, ' ', 1)) as VisDate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080;"&gt;//Successfully strips time&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;Resident aVisit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000; font-size: 13.3333px;"&gt;Once loaded, VisDate is a date, while VisitStartDate is a timestamp:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/196925_Capture.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;So I'm mystified as to why the same function works in the load script but not in my function, called in the load script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2018 20:16:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Function-won-t-strip-time-off-of-date/m-p/60008#M3979</guid>
      <dc:creator>Lauri</dc:creator>
      <dc:date>2018-03-20T20:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Function won't strip time off of date</title>
      <link>https://community.qlik.com/t5/App-Development/Function-won-t-strip-time-off-of-date/m-p/60009#M3980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's probably because you already loaded values to VisitStartDate with the same numeric value, and Qlik is only capable of storing one textual representation per numeric value / symbol in one field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would need use a new field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2018 20:38:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Function-won-t-strip-time-off-of-date/m-p/60009#M3980</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2018-03-20T20:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Function won't strip time off of date</title>
      <link>https://community.qlik.com/t5/App-Development/Function-won-t-strip-time-off-of-date/m-p/60010#M3981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That explains it! I just confirmed your answer by changing the field name in the preceding load. (I load the flat file into a temporary table, where I named the field "VisitStartDate." The load described in this post happens next.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't know that Qlik "remembers" what happened with the first load of a given field name. I assumed that a subsequent use of a field name completely overwrote any previous data. A good lesson!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2018 13:15:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Function-won-t-strip-time-off-of-date/m-p/60010#M3981</guid>
      <dc:creator>Lauri</dc:creator>
      <dc:date>2018-03-21T13:15:56Z</dc:date>
    </item>
  </channel>
</rss>

