Calculating Date Field with today's date from datetime.date.today()?
An update Cursor will out perform the field calculator 100% of the time.
You need to write this as an expression:
import arcpy, datetime
fc = r'C:\GIS\CARGIS\SHAPES.gdb\CRASH_ON_2013'
field = "DTCARXTRCT"
exp = '''def add_date():
import time
return time.strftime("%Y/%m/%d")'''
arcpy.CalculateField_management(fc, field, 'add_date()',
'PYTHON', exp)
print 'done'
datetime.date.today() did not work in field calculator, switched to strftime.
OR, if you want to do it the better way where you can feed your own variables in, use a cursor:
import arcpy, datetime
fc = r'C:\GIS\CARGIS\SHAPES.gdb\CRASH_ON_2013'
field = "DTCARXTRCT"
with arcpy.da.UpdateCursor(fc, [field]) as rows:
for row in rows:
rows.updateRow([datetime.date.today()])
print 'done'