Calculate date difference between now and a previous date from arcade

47 Views Asked by At

I can't find the error in my code. I am trying to calculate the difference between the current days date and a previous inspection date. I want the difference to be calculated in days. I am using ArcGIS Pro's field calculator for this task and am using Arcade code, but I am open to Python suggestions too.

Field Calculator verifies and states the "Expression is valid" but when I run the code in Field Calculator for the 'Days_Since_Last_Inspection' field, the attribute table is not populated with any values... the field still reads <Null> for each attribute in the 'Days_Since_Last_Inspection' field.

var startDate=Date($feature.Last_Inspection_Date)
var endDate=Now()
Var result=DateDiff(endDate,startDate,'days')
return result

I am using ArcGIS Pro version 2.9.5, the 'Last_Inspection_Date' field is a date field formatted as yyyy-M-d, and the 'Days_Since_Last_Inspection' field is formatted as numeric with a Short data type.

0

There are 0 best solutions below