<?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 Calculate time duration from military time with ArcMap Field Calculator in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/calculate-time-duration-from-military-time-with/m-p/544211#M30898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class=""&gt;&lt;P&gt;I have two text fields (STRTTIME, ENDTIME) which are are formatted as military time with leading zeros. For example, 0540, 1655.&lt;/P&gt;&lt;P&gt;I want to calculate a new field with the time duration as integers (in minutes). How can I go about this using the Field Calculator in ArcMap?&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Jul 2019 16:20:23 GMT</pubDate>
    <dc:creator>DanSeidensticker</dc:creator>
    <dc:date>2019-07-15T16:20:23Z</dc:date>
    <item>
      <title>Calculate time duration from military time with ArcMap Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-time-duration-from-military-time-with/m-p/544211#M30898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class=""&gt;&lt;P&gt;I have two text fields (STRTTIME, ENDTIME) which are are formatted as military time with leading zeros. For example, 0540, 1655.&lt;/P&gt;&lt;P&gt;I want to calculate a new field with the time duration as integers (in minutes). How can I go about this using the Field Calculator in ArcMap?&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2019 16:20:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-time-duration-from-military-time-with/m-p/544211#M30898</guid>
      <dc:creator>DanSeidensticker</dc:creator>
      <dc:date>2019-07-15T16:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time duration from military time with ArcMap Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/calculate-time-duration-from-military-time-with/m-p/544212#M30899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/2120" target="_blank"&gt;Dan,&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a Python function in&amp;nbsp;field&amp;nbsp;calculator to determine difference in time.&amp;nbsp; Since your data is in military time with leading zeros it is even easier.&amp;nbsp; Create a function as noted below.&amp;nbsp; This function takes the string&amp;nbsp;parameters, convers them to datatime variables, calculates the difference in seconds and return this value&amp;nbsp;multiplied by 60 to give you minutes.&amp;nbsp;This script does assume the times are within a single 24-hour&amp;nbsp;day and that STRTTIME is before ENDTIME.&amp;nbsp; It can be modified to include&amp;nbsp;times on multiple days if the date is provided as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; datetime

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; deltaTime &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;start&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; end&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
  starttime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strptime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;start&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%H%M'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  endtime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strptime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;end&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%H%M'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;endtime &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; starttime&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;seconds&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;60&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can call this function in field calculator using &lt;STRONG&gt;deltaTime(!STRTTIME!, !ENDTIME!)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Field Calculator" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/453106_Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:33:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/calculate-time-duration-from-military-time-with/m-p/544212#M30899</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2021-12-11T23:33:07Z</dc:date>
    </item>
  </channel>
</rss>

