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")
1 Answer 1
Try this code snippet:
expression = "!ORIGDTDATE!+\" \"+ !ORIGDTTIME!"
arcpy.CalculateField_management(fc, "ORIGDTDATE",expression,"PYTHON_9.3")
answered Nov 21, 2016 at 19:14
-
This syntax is incorrect for the calcExpression and I do not want to calculate it as a TEXT field.geewest– geewest2016年11月21日 19:16:20 +00:00Commented Nov 21, 2016 at 19:16
-
updated expressionartwork21– artwork212016年11月21日 19:17:33 +00:00Commented Nov 21, 2016 at 19:17
-
That is also incorrect.geewest– geewest2016年11月21日 19:21:27 +00:00Commented Nov 21, 2016 at 19:21
-
Ok, updated again, got this to work on existing date field.artwork21– artwork212016年11月21日 19:24:27 +00:00Commented Nov 21, 2016 at 19:24
lang-py