#Calculate Date Field expression = time.strftime("%Y") arcpy.CalculateField_management("Boundary", "Date", expression, "PYTHON")
#Calculate Date Field import time import datetime now = datetime.date.today() expression = now.strftime("%m%d%y") arcpy.CalculateField_management("Boundary", "Date", expression, "PYTHON")
Solved! Go to Solution.
Thank you James, but I tried your code and I get a null value for the date field. I am not sure if the calculate field management method is recognizing as a string, a real expression.
Here is my code#Calculate Date Field import time import datetime #current date d1 = datetime.today() _currdate = datetime.strftime(d1, "%Y-%m-%d") arcpy.CalculateField_management("Boundary", "Date", _currdate, "PYTHON")
arcpy.CalculateField_management("Boundary", "Date", d1, "PYTHON")
d1 = datetime.today()will error out and not assign the variable no matter what imports I try in the IDE.
d1 = = date.today()
It is a date type but that did not work, I got a null value
#current date d1 = datetime.datetime.today() print str(d1)