I am attempting to calculate a field based on date and time of two other fields. How should my expression read in ArcPy? Both fields are date type with the values of the ORIGDTDATE reading 11/18/2016 while ORIGDTTIME reading 9:52:00 AM I would like for my new output for ORIGDTDATE to equal 11/18/2016 9:52:00 AM

import arcpy
calcExpression =  [!ORIGDTDATE!] + [!ORIGDTTIME!]
arcpy.CalculateField_management(fc, "ORIGDTDATE",ORIGDTDATE + !ORIGDTTIME!,"PYTHON_9.3")

Try this code snippet:

expression =  "!ORIGDTDATE!+\" \"+ !ORIGDTTIME!"
arcpy.CalculateField_management(fc, "ORIGDTDATE",expression,"PYTHON_9.3")
| improve this answer | |
  • This syntax is incorrect for the calcExpression and I do not want to calculate it as a TEXT field. – geewest Nov 21 '16 at 19:16
  • updated expression – artwork21 Nov 21 '16 at 19:17
  • That is also incorrect. – geewest Nov 21 '16 at 19:21
  • Ok, updated again, got this to work on existing date field. – artwork21 Nov 21 '16 at 19:24

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.