I have 2 date fields in my feature class. If the start date is greater than the end date, I want to add 24 hours to the end date. I am getting a SetValue error.

cursor = arcpy.UpdateCursor("PolyFc")
for row in cursor:
    if row.getValue("START_DATE_VAL") > row.getValue("END_DATE_VAL"):
        row.setValue("END_DATE_VAL", row.getValue("END_DATE_VAL") + datetime.timedelta(hours=24))
del cursor

Probably seeing an AttributeError exception? Use setValue (not SetValue).

  • Thanks! Oh man I can't believe I missed that. I updated my code above. – Andrew Apr 7 '15 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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