<?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>question Re: Resolving date difference on Apache NIFI in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Resolving-date-difference-on-Apache-NIFI/m-p/374390#M241970</link>
    <description>&lt;P&gt;thank you so much! i'm moving forward again!&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2023 04:11:20 GMT</pubDate>
    <dc:creator>maglinvinn</dc:creator>
    <dc:date>2023-07-25T04:11:20Z</dc:date>
    <item>
      <title>Resolving date difference on Apache NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Resolving-date-difference-on-Apache-NIFI/m-p/374372#M241961</link>
      <description>&lt;P&gt;Good afternoon all, and thank you in advance.&lt;BR /&gt;&lt;BR /&gt;I have a Apache NIFI solution that is pulling from API a pair of dates, i've grabbed out the relevant bit from the json:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"arrival&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"2023&lt;/SPAN&gt;&lt;SPAN&gt;-07&lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;T&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;.263Z&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"departure&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"2023&lt;/SPAN&gt;&lt;SPAN&gt;-07&lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;T&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;.263Z&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;And i'm successfully getting those values down to attributes via extract attributes.&lt;BR /&gt;&lt;BR /&gt;However when i perform a toNumber() on them to convert to miliseconds since EPOCH to determine the time between the dates, i return an empty condition upon review of my flow in the queue.&lt;BR /&gt;&lt;BR /&gt;I've gone so far as to arbitarily grab "NOW()" and attempt to toNumber() it but with the same result as trying to modify the above attributes.&amp;nbsp; incidentally NOW() returns a format like:&amp;nbsp;&lt;SPAN&gt;Mon Jul 24 &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;9&lt;/SPAN&gt;&lt;SPAN&gt;:21 UTC 2023 - its different that my UTC formatted items, but it also doesn't want to toNumber() - returning again an empty value&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-07-24 133844.png" style="width: 551px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/38075iA63CBF4BC652D0D0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-07-24 133844.png" alt="Screenshot 2023-07-24 133844.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Shows me attempting to convert the attributes:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image" style="width: 218px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/38076i566DF1433E3D528B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;BR /&gt;and this shows the flow in the queue after hitting that updateattrs.&amp;nbsp; The datetimestamps are all there, but the toNumber() fails for both format styles...&amp;nbsp; timenow was set earlier with a simple ${now()}, and none of them are formatted.&amp;nbsp; when attempting to format them, actually, i get other errors.&lt;BR /&gt;&lt;IMG src="https://ip1.i.lithium.com/f09ed606fb293fbe92119fd6844740983e0ef9a8/68747470733a2f2f63646e2e646973636f72646170702e636f6d2f6174746163686d656e74732f3739393835323831353931323030393733392f313133333036323234353630363234383437392f696d6167652e706e67" border="0" /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm struggling to work with dates in nifi and hoping someone has some guidance for me.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;NOTE: yes, my nifi is reskinned - its easier on the eyes.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 18:46:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Resolving-date-difference-on-Apache-NIFI/m-p/374372#M241961</guid>
      <dc:creator>maglinvinn</dc:creator>
      <dc:date>2023-07-24T18:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving date difference on Apache NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Resolving-date-difference-on-Apache-NIFI/m-p/374377#M241966</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/106155"&gt;@maglinvinn&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get the expected result, you need to convert the string type datetime to datetime type before calling the toNumber() function. The conversion can be done using the toDate() function&amp;nbsp; (see: &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#todate" target="_blank"&gt;https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#todate&lt;/A&gt; ), For example the &lt;STRONG&gt;arrivaltimeinmillis&lt;/STRONG&gt; will have the following value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${timearrival:toDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"):toNumber()}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you find this is helpful, please &lt;STRONG&gt;accept&lt;/STRONG&gt; solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 21:29:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Resolving-date-difference-on-Apache-NIFI/m-p/374377#M241966</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-07-24T21:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving date difference on Apache NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Resolving-date-difference-on-Apache-NIFI/m-p/374390#M241970</link>
      <description>&lt;P&gt;thank you so much! i'm moving forward again!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 04:11:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Resolving-date-difference-on-Apache-NIFI/m-p/374390#M241970</guid>
      <dc:creator>maglinvinn</dc:creator>
      <dc:date>2023-07-25T04:11:20Z</dc:date>
    </item>
  </channel>
</rss>

