<?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: Calculating Date Difference in Field Calculator? in ArcGIS GeoEvent Server Questions</title>
    <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/calculating-date-difference-in-field-calculator/m-p/1224135#M3849</link>
    <description>&lt;P&gt;It turns out there was nothing wrong with my expression. The reason I was getting a NULL value is that I failed to include the two date fields in the Field Mapper activity prior to the Field Calculator.&amp;nbsp; This wasn't just an oversight on my part. It was more of a lack of understand of how the plumbing works in GeoEvent Services.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2022 23:41:48 GMT</pubDate>
    <dc:creator>JonSwoveland</dc:creator>
    <dc:date>2022-10-20T23:41:48Z</dc:date>
    <item>
      <title>Calculating Date Difference in Field Calculator?</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/calculating-date-difference-in-field-calculator/m-p/1223893#M3848</link>
      <description>&lt;P&gt;OK, I solved this myself. Solution posted below.&lt;/P&gt;&lt;P&gt;I have a GeoEvent Definition with two date fields: Date_Entered &amp;amp; Date_Exited.&amp;nbsp; As you may suspect, these fields indicate&amp;nbsp; the date/time when an event (vehicle) enters and exists a GeoFence.&lt;/P&gt;&lt;P&gt;What I need to do is create a GeoEvent Service that calculates the difference betweens the two dates (in minutes), to determine how many minutes (n_minutes) the vehicle was inside the GeoFence.&amp;nbsp; If n_minutes &amp;gt; x, the feature representing the GeoFence will have one of its attributes updated to indicate it was "patrolled".&lt;/P&gt;&lt;P&gt;Using&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-geoevent-server-documents/calculate-total-time-spent-at-a-location/ta-p/1055149" target="_blank" rel="noopener"&gt;this tutorial&lt;/A&gt;&amp;nbsp;I created a table in the geodatabase to store the patrol info for each GeoFence (vehicle id, geofence name, date enterered and date exited), and the required GeoEvent inputs / outputs and services to update this table.&amp;nbsp; This is all working.&lt;/P&gt;&lt;P&gt;Where I am stuck is using these date fields in a Field Calculator processor's expression.&amp;nbsp; I thought the Field Calculator automatically converts date fields to their milliseconds since epoch representation, so I tried:&lt;/P&gt;&lt;P&gt;((Date_Exited - Date_Entered) / 1000) / 60.&amp;nbsp; &amp;nbsp; This results in a NULL value.&lt;/P&gt;&lt;P&gt;I then tried:&lt;/P&gt;&lt;P&gt;((toLong(Date_Exited) - toLong(Date_Entered)) / 1000) / 60. This also results in a NULL value.&lt;/P&gt;&lt;P&gt;Is there any way to do this kind of Date math?&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 23:39:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/calculating-date-difference-in-field-calculator/m-p/1223893#M3848</guid>
      <dc:creator>JonSwoveland</dc:creator>
      <dc:date>2022-10-20T23:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Date Difference in Field Calculator?</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/calculating-date-difference-in-field-calculator/m-p/1224135#M3849</link>
      <description>&lt;P&gt;It turns out there was nothing wrong with my expression. The reason I was getting a NULL value is that I failed to include the two date fields in the Field Mapper activity prior to the Field Calculator.&amp;nbsp; This wasn't just an oversight on my part. It was more of a lack of understand of how the plumbing works in GeoEvent Services.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 23:41:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/calculating-date-difference-in-field-calculator/m-p/1224135#M3849</guid>
      <dc:creator>JonSwoveland</dc:creator>
      <dc:date>2022-10-20T23:41:48Z</dc:date>
    </item>
  </channel>
</rss>

