3

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")
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 21, 2016 at 19:09

1 Answer 1

4

Try this code snippet:

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.