Why is arcpy.CalculateField_management() writing 1899-12-30 00:00:00 instead of expec

المشرف العام

Administrator
طاقم الإدارة
I'm using ArcGIS 10.3.1 for Desktop to test before writing an answer to How to enter date with arcpy.GetParameterAsText with arcpy? I have written the test code below that I am running against a test feature class (testFC) with four line features to try and update its dateField with a constant date value of "01.07.2015".

import arcpydmyString = "01.07.2015"fc = r"C:\temp\test.gdb\testFC"item = "dateField"dmyDate = datetime.datetime.strptime(dmyString,'%d.%m.%Y')print dmyDatearcpy.CalculateField_management(fc,item,dmyDate,"PYTHON")with arcpy.da.SearchCursor(fc,[item]) as cursor: for row in cursor: print row[0]I think the above should work, and from the output below you can see that the date object (dmyDate) seems to be created fine, but the values written to each of the four features are not what I would expect.

>>> ================================ RESTART ================================>>> 2015-07-01 00:00:001899-12-30 00:00:001899-12-30 00:00:001899-12-30 00:00:001899-12-30 00:00:00>>> Can someone explain why 1899-12-30 00:00:00 is being written instead of 2015-07-01 00:00:00?



أكثر...
 
أعلى