I'm looking for help tweaking the python code discussed here: Attribute Table Subtract Value From Previous Value
I'm having trouble figuring out how to adjust it for a date field in which I want to subtract a time by the previous time to get gaps. Here is what I have so far and the error received:
import arcpy
... from arcpy import da
... vertices = "CBR05_T2_10_1_2014_WLanduse_1"
... gap1=0
... with arcpy.da.UpdateCursor(vertices, ["INDEX_", "Time", "GapDiff"]) as cursor:
... for row in cursor:
... gap2 = row[1]
... row[2] = datetime(gap2 - gap1)
... gap1 = gap2
... cursor.updateRow(row) ...
Runtime error Traceback (most recent call last): File "", line 8, in TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'int'
أكثر...
I'm having trouble figuring out how to adjust it for a date field in which I want to subtract a time by the previous time to get gaps. Here is what I have so far and the error received:
import arcpy
... from arcpy import da
... vertices = "CBR05_T2_10_1_2014_WLanduse_1"
... gap1=0
... with arcpy.da.UpdateCursor(vertices, ["INDEX_", "Time", "GapDiff"]) as cursor:
... for row in cursor:
... gap2 = row[1]
... row[2] = datetime(gap2 - gap1)
... gap1 = gap2
... cursor.updateRow(row) ...
Runtime error Traceback (most recent call last): File "", line 8, in TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'int'
أكثر...