Hello everyone,
This is my first Geoprocessing Service based on a Python script tool.. How do I process a datetime field in a Python script tool?
I wrote a Python script tool and one of the parameter fields gets a DateTime value. This field fails with the following error message.
Python tool Parameters (Properties --> Parameters)
Python source Code:
in_requesteddate = arcpy.GetParameterAsText(5)
arcpy.AddMessage("in_requesteddate = " + in_requesteddate)
in_featureclass = arcpy.GetParameter(6)
requested_datetime = datetime.strptime(in_requesteddate, '%m/%d/%Y')
Error Message:
Traceback (most recent call last):
File "C:\Workspace\GeocoprocessingServices\Sample\Toolbox.tbx#Script.py", line 25, in <module>
AttributeError: 'module' object has no attribute 'strptime'
Is this field processed as a text field or as a DateTime field?
Do I need this conversion datetime.strptime .....
Thanks
check how datetime was imported
was it like
from datetime import datetime
or was it like
import datetime
since the strptime func is in datetime.datetime
dir(datetime.datetime)
[... snip....
'strftime', 'strptime', 'time',... more snip...]