In my ArcPy script I have an input parameter for the Date, so the user is asked to input a date value (time is not needed) using the data type GPDate. In the script I calculate a new field, field data type DATE, which should include for all features the date that the user entered.
I cannot find a way how to populate this new field with the value of the input parameter. My code:
date = parameters[0].valueAsText
arcpy.management.CalculateField(myFC, "myField", date, "PYTHON3", "", "DATE")
I already tried 100 varieties with datetime, strftime and different formatting of the date (my default input is dd.mm.YYYY), but either I get an error indicating "unexpected EOF while parsing" or that the value cannot be written to the attribute table.
parameters[0].value
instead ofvalueAsText
?