<?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 elapsed time as an attribute field in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574094#M91778</link>
    <description>&lt;P&gt;Looks like you're getting the date in a string format, probably month/day/year. Take a look at the &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt; method I mentioned above, you can parse the date string that way.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jan 2025 19:12:20 GMT</pubDate>
    <dc:creator>DavidSolari</dc:creator>
    <dc:date>2025-01-09T19:12:20Z</dc:date>
    <item>
      <title>Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574058#M91771</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to calculate the number of days a permit has been open since it was issued. I am using this python code:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;datetime.datetime.now().day - !permitissdate!&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;EM&gt;permitissdate &lt;/EM&gt;is a &lt;U&gt;date&lt;/U&gt; field, and the field to which the calculation is being written (&lt;EM&gt;timeopen&lt;/EM&gt;) is a &lt;U&gt;short&lt;/U&gt; field.&lt;/P&gt;&lt;P&gt;I am getting the following error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;TypeError: unsupported operand type(s) for -: 'int' and 'str'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Could someone help me identify the problem?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;Deb.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 18:13:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574058#M91771</guid>
      <dc:creator>dsinha</dc:creator>
      <dc:date>2025-01-09T18:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574071#M91772</link>
      <description>&lt;P&gt;Your expression is calculating the difference between the current day of the month and the permit date, which probably isn't what you want. Try&lt;FONT face="courier new,courier"&gt;(datetime.datetime.now() - !permitissdate!).days&lt;/FONT&gt; instead. On top of that, you'll want &lt;FONT face="courier new,courier"&gt;utcnow&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;now&lt;/FONT&gt; if your permit dates are stored in UTC instead of a consistent local time. Either way, this ran with no issue in Pro 3.1. If you're using ArcMap or a much older version of Pro the Field Calculator brings dates in as formatted strings instead of datetime objects. To fix this you'll need to parse that string in whatever format is spat out using the &lt;A href="https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior" target="_self"&gt;&lt;FONT face="courier new,courier"&gt;datetime.datetime.strptime&lt;/FONT&gt;&lt;/A&gt; method.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 19:03:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574071#M91772</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-09T19:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574087#M91775</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/4413"&gt;@DavidSolari&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tried that and I got this error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;File "&amp;lt;expression&amp;gt;", line 1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(datetime.datetime.now() -&amp;nbsp;u"11/23/2022").days&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;^&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SyntaxError: invalid non-printable character U+00A0&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The date the error is referring to is actually 1/23/2024, and not 11/23/2024.&lt;/P&gt;&lt;P&gt;I am using ArcGIS Pro 3.2.1&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 18:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574087#M91775</guid>
      <dc:creator>dsinha</dc:creator>
      <dc:date>2025-01-09T18:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574090#M91776</link>
      <description>&lt;P&gt;Odd, I guess a nonstandard character snuck into my answer. Try typing it out by hand and it should work, or at least you'll get a better error message. I wouldn't trust the date it reports until all the other errors are solved.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 19:02:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574090#M91776</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-09T19:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574092#M91777</link>
      <description>&lt;P&gt;I typed it out and the error message changed to:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/4413"&gt;@DavidSolari&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 19:06:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574092#M91777</guid>
      <dc:creator>dsinha</dc:creator>
      <dc:date>2025-01-09T19:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574094#M91778</link>
      <description>&lt;P&gt;Looks like you're getting the date in a string format, probably month/day/year. Take a look at the &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt; method I mentioned above, you can parse the date string that way.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 19:12:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574094#M91778</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-09T19:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574124#M91783</link>
      <description>&lt;P&gt;I am sorry&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/4413"&gt;@DavidSolari&lt;/a&gt;,&amp;nbsp;I am not well-versed in Python.&lt;/P&gt;&lt;P&gt;I tried to figure out the issue and this is as far as I got:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;datetime.datetime.strptime(%m/%d/%Y) - !permitissdate!).days&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The error is:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;File "&amp;lt;expression&amp;gt;", line 1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;datetime.datetime.strptime(%m/%d/%Y) - u"1/23/2024").days&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ^&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SyntaxError: invalid syntax&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 19:57:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1574124#M91783</guid>
      <dc:creator>dsinha</dc:creator>
      <dc:date>2025-01-09T19:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating elapsed time as an attribute field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1581037#M92571</link>
      <description>&lt;P&gt;Wanted to report back that Esri Technical support helped me find a resolution to this issue. The solution has two steps:&lt;/P&gt;&lt;P&gt;1) Calculating the number of elapsed days&lt;/P&gt;&lt;P&gt;Used an Arcade expression:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var startDate = Date($feature.FieldName)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var endDate = Date()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var result = DateDiff(endDate, startDate, 'Day')&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return result&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the &lt;U&gt;Calculate Field&lt;/U&gt; tool select &lt;U&gt;Arcade&lt;/U&gt; as the expression type.&amp;nbsp;&lt;/SPAN&gt;In the first line, replace F&lt;EM&gt;ieldName&lt;/EM&gt; with the field name.&lt;/P&gt;&lt;P&gt;2) Updating the number of elapsed days daily&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Schedule the &lt;U&gt;Calculate Field&lt;/U&gt;&amp;nbsp;geoprocessing tool in ArcGIS Pro as a scheduled task with a daily frequency. Details here:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/schedule-geoprocessing-tools.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/schedule-geoprocessing-tools.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 21:39:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculating-elapsed-time-as-an-attribute-field/m-p/1581037#M92571</guid>
      <dc:creator>dsinha</dc:creator>
      <dc:date>2025-01-31T21:39:08Z</dc:date>
    </item>
  </channel>
</rss>

