<?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: Add seconds to a datetime in arcpy field calculator  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-seconds-to-a-datetime-in-arcpy-field/m-p/235097#M18232</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jon, Thanks so much.&amp;nbsp; It worked perfectly.&amp;nbsp; Really appreciate the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Dec 2015 03:01:46 GMT</pubDate>
    <dc:creator>IanIrmischer</dc:creator>
    <dc:date>2015-12-18T03:01:46Z</dc:date>
    <item>
      <title>Add seconds to a datetime in arcpy field calculator</title>
      <link>https://community.esri.com/t5/python-questions/add-seconds-to-a-datetime-in-arcpy-field/m-p/235095#M18230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have a date field called date with date times in format 4/1/2016 6:40:00 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a second field called times that is a double with numbers of seconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to use arcpy.CalculateField_management to add the seconds to the time in a new date field called futuretime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can do this in the field calculator in VB using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;DateAdd ( "s", [times], [date] )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;But I am trying to use a script to run through a bunch of files in a for loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;I started with &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;for files in allFC:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(files, "futuretime",?????, "PYTHON_9.3",????)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;but I can not figure out the code to fill into the ?????s&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;Thanks for any help,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;Ian&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2015 06:02:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-seconds-to-a-datetime-in-arcpy-field/m-p/235095#M18230</guid>
      <dc:creator>IanIrmischer</dc:creator>
      <dc:date>2015-12-17T06:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Add seconds to a datetime in arcpy field calculator</title>
      <link>https://community.esri.com/t5/python-questions/add-seconds-to-a-datetime-in-arcpy-field/m-p/235096#M18231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use timedelta to add the two attributes together. For example,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14503405081537703 jive_text_macro" data-renderedposition="50_8_912_32" jivemacro_uid="_14503405081537703"&gt;&lt;P&gt;arcpy.CalculateField_management(files, "futuretime", "datetime.datetime.strptime(!date!,'%d/%m/%Y %H:%M:%S') + datetime.timedelta(seconds=!seconds!)", "PYTHON_9.3")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may want to check &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;the &lt;/SPAN&gt;&lt;SPAN style="color: #287433; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;A href="https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior"&gt;datetime&lt;/A&gt;​&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; module to make sure I've got the format right.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2015 08:26:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-seconds-to-a-datetime-in-arcpy-field/m-p/235096#M18231</guid>
      <dc:creator>JonMorris2</dc:creator>
      <dc:date>2015-12-17T08:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Add seconds to a datetime in arcpy field calculator</title>
      <link>https://community.esri.com/t5/python-questions/add-seconds-to-a-datetime-in-arcpy-field/m-p/235097#M18232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jon, Thanks so much.&amp;nbsp; It worked perfectly.&amp;nbsp; Really appreciate the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Dec 2015 03:01:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-seconds-to-a-datetime-in-arcpy-field/m-p/235097#M18232</guid>
      <dc:creator>IanIrmischer</dc:creator>
      <dc:date>2015-12-18T03:01:46Z</dc:date>
    </item>
  </channel>
</rss>

