I've been trying to load data from an excel spreadsheet into existing feature classes, but I've been having some trouble with the dates.

I've written a script that compares the values in the spreadsheet & in the feature class.

arcpy.MakeFeatureLayer_management(engPath, 'engPath')  
arcpy.SelectLayerByAttribute_management('engPath', "NEW_SELECTION", d)
EngCursor = arcpy.da.SearchCursor('engPath', '*')
for row in EngCursor:
    for item in Master_Dict.itervalues():
        print item[1], row[3]
        if item[1] == row[3]:
            i = 0
            j = 2
            while i < 34:
                if item[i] == row[j]:
                    print "Values are the same"
                    print "NOPE!", item[i], row[j]

When I run the script, I get values like this:

Excel Spreadsheet Value = "41526.0"
Feature Class Value = "2013-09-09 00:00:00"

Those two values are supposed to be identical, and the excel value for the cell does show "09/09/2013". I've checked the spreadsheet, and the column is set to a date data type.

I don't know how to tell arc that it is indeed looking at a date data type.

  • One approach is to convert your date-time value into a float value then do the comparison. – Hornbydd Mar 14 '14 at 15:28
  • 1
    Why was this marked as off-topic? This question is dealing with software development yes, but it's talking about loading data into Arc, a GIS platform. In any case, I was able to figure out a solution using xlrds' xldate_as_tuple method and using python's datetime module – Schack Mar 17 '14 at 13:29

Using Python, this shows how to convert the Excel serial date to YYYY-MM-DD format.
The Time portion is not included. https://stackoverflow.com/questions/19036709/when-reading-date-from-excel-using-xlrd-in-python-datetime-randomly-becomes-flo

Not the answer you're looking for? Browse other questions tagged or ask your own question.