<?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: Field Calculator - Dates using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-calculator-dates-using-python/m-p/473100#M36950</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;'module' object is not callable means that you are treating a module as a function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;datetime is a module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datetime(int(rasterParts[1][0:4]), ...) is trying to "call" the datetime module, instead of createing an object of type datetime.datetime.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Feb 2011 09:48:53 GMT</pubDate>
    <dc:creator>NiklasNorrthon</dc:creator>
    <dc:date>2011-02-22T09:48:53Z</dc:date>
    <item>
      <title>Field Calculator - Dates using Python</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-dates-using-python/m-p/473099#M36949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to parse a string field into date field but having some issues with the ArcGIS field calculator.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Strings are in the format of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;idr02_20110203_0000_256.png&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;being&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;idr02_YYYYMMDD_HHMM_256.png&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tested my string parsing in the python console but for having some difficulty getting ArcGIS field calculator to accept it in the following format:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeBlock=&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def MyFunction(nameInput):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; rasterParts = nameInput.split("_")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; newDate = datetime(int(rasterParts[1][0:4]), int(rasterParts[1][4:6]),int(rasterParts[1][6:8]),int(rasterParts[2][0:2]),int(rasterParts[2][2:4]) )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return newDate &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-----&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression=&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;---&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MyFunction( !Name! )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;--&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It keeps coming back with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Messages&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: MyFunction("idr02_20110203_0000_256.png")&amp;nbsp; &amp;lt;type 'exceptions.TypeError'&amp;gt;: 'module' object is not callable&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anybody spot the error or have any alternative methods for parsing out the date?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Feb 2011 03:40:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-dates-using-python/m-p/473099#M36949</guid>
      <dc:creator>AndrewWise</dc:creator>
      <dc:date>2011-02-22T03:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator - Dates using Python</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-dates-using-python/m-p/473100#M36950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;'module' object is not callable means that you are treating a module as a function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;datetime is a module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datetime(int(rasterParts[1][0:4]), ...) is trying to "call" the datetime module, instead of createing an object of type datetime.datetime.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Feb 2011 09:48:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-dates-using-python/m-p/473100#M36950</guid>
      <dc:creator>NiklasNorrthon</dc:creator>
      <dc:date>2011-02-22T09:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator - Dates using Python</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-dates-using-python/m-p/473101#M36951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Niklas,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I knew it would be something simple. Adding the extra datetime.datetime reference worked fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Feb 2011 22:14:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-dates-using-python/m-p/473101#M36951</guid>
      <dc:creator>AndrewWise</dc:creator>
      <dc:date>2011-02-22T22:14:49Z</dc:date>
    </item>
  </channel>
</rss>

