<?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: Python arcpy.GetParameterAsText() for a Date field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-arcpy-getparameterastext-for-a-date-field/m-p/565783#M44313</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check how datetime was imported&lt;/P&gt;&lt;P&gt;was it like&lt;/P&gt;&lt;P&gt;from datetime import datetime&lt;/P&gt;&lt;P&gt;or was it like&lt;/P&gt;&lt;P&gt;import datetime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since the strptime func is in datetime.datetime&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;dir&lt;SPAN class="punctuation 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;

&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; snip&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
 &lt;SPAN class="string token"&gt;'strftime'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'strptime'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'time'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; more snip&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:22:59 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-12T00:22:59Z</dc:date>
    <item>
      <title>Python arcpy.GetParameterAsText() for a Date field</title>
      <link>https://community.esri.com/t5/python-questions/python-arcpy-getparameterastext-for-a-date-field/m-p/565782#M44312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my first Geoprocessing Service based on a Python script tool.. How do I process a datetime field in a Python script tool?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote a Python script tool and one of the parameter fields&amp;nbsp;gets a DateTime value. This field&amp;nbsp;fails with the following error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Python tool Parameters&lt;/STRONG&gt; (Properties --&amp;gt; Parameters)&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;RequestedDate&amp;nbsp;&amp;nbsp; Date&lt;/LI&gt;&lt;LI&gt;Rest of parameters are numeric or text fields&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Python source Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;in_requesteddate = arcpy.GetParameterAsText(5)&lt;/P&gt;&lt;P&gt;arcpy.AddMessage("in_requesteddate = " + in_requesteddate)&lt;/P&gt;&lt;P&gt;in_featureclass = arcpy.GetParameter(6)&lt;/P&gt;&lt;P&gt;requested_datetime = datetime.strptime(in_requesteddate, '%m/%d/%Y')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error Message:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Workspace\GeocoprocessingServices\Sample\Toolbox.tbx#Script.py", line 25, in &amp;lt;module&amp;gt;&lt;BR /&gt;AttributeError: 'module' object has no attribute 'strptime'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this field processed as a text field or as a DateTime field?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need this conversion datetime.strptime .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2018 20:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-arcpy-getparameterastext-for-a-date-field/m-p/565782#M44312</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2018-05-07T20:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python arcpy.GetParameterAsText() for a Date field</title>
      <link>https://community.esri.com/t5/python-questions/python-arcpy-getparameterastext-for-a-date-field/m-p/565783#M44313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check how datetime was imported&lt;/P&gt;&lt;P&gt;was it like&lt;/P&gt;&lt;P&gt;from datetime import datetime&lt;/P&gt;&lt;P&gt;or was it like&lt;/P&gt;&lt;P&gt;import datetime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since the strptime func is in datetime.datetime&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;dir&lt;SPAN class="punctuation 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;

&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; snip&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
 &lt;SPAN class="string token"&gt;'strftime'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'strptime'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'time'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; more snip&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:22:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-arcpy-getparameterastext-for-a-date-field/m-p/565783#M44313</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T00:22:59Z</dc:date>
    </item>
  </channel>
</rss>

