2

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"
                else:
                    print "NOPE!", item[i], row[j]
                i+=1
                j+=1

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.

closed as off-topic by blah238, PolyGeo, Paul, Fezter, Simbamangu Mar 15 '14 at 5:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here unless they relate directly to Geographical Information Systems, but they can be asked on Stack Overflow." – blah238, PolyGeo, Paul, Fezter, Simbamangu
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
1

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.