Skip to main content
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
edited tags; edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Calculate Calculating Date Field -with today's date from datetime.date.today()?

Source Link

Calculate Date Field - today's date from datetime.date.today

I'm working on part of tool that will use arcpy.CalculateField_management to add the current date to the attribut table. I've wandered far and wide on the interwebs and can't seem to find the resolution to this issue.

When using this code, i get the value "12:00:00 AM"

    input = r'C:\GIS\CARGIS\SHAPES.gdb\CRASH_ON_2013'
    today = datetime.date.today()
    dte = today.strftime('%m/%d/%Y')
    arcpy.CalculateField_management(input,"DTCARXTRCT",dte,"PYTHON")

When using this code, I get the value "06/19/1905" from today's date of "10/07/2014"

    input = r'C:\GIS\CARGIS\SHAPES.gdb\CRASH_ON_2013'
    today = datetime.date.today()
    dte = str(today)
    arcpy.CalculateField_management(input,"DTCARXTRCT",dte,"PYTHON")

Any thoughts on what I'm doing wrong? I'd like to avoid using the update cursor, but will do so if it's the last option.