AnsweredAssumed Answered

Date - Today's date in Python?

Question asked by ionarawilson on Jun 13, 2013
Latest reply on Dec 10, 2014 by Dan_Patterson
Hi guys,

I am writing a python script that adds a feature to geodatabase feature class. Some fields the user has to enter manually and some are automatic. However the date field output is an incorrect date of 7/5/1905. Does anybody have any idea why this is happening? I have tried everything I could find and nothing worked. I am using a file geodatabase, the date field is of date type and my computer's setting has the correct today's date. Thank you for any help!

Here is the code

#Calculate Date Field expression = time.strftime("%Y") arcpy.CalculateField_management("Boundary", "Date", expression, "PYTHON")

If I change the code I get a date of 3/29/1969. Here is the code for that:

#Calculate Date Field                                                     import time                                                               import datetime                                                           now =                                               expression = now.strftime("%m%d%y")                                                                                                                 arcpy.CalculateField_management("Boundary", "Date", expression, "PYTHON")