Select to view content in your preferred language

Field of type date being interpreted as a string

206
1
06-04-2024 12:44 PM
clt_cabq
Occasional Contributor III

I have a feature class in which I'm trying to calculate the number of days between now, and when a property was last inspected. However, when I try to use the variable for the last inspection date Python/arcgis seems to think LastInsp is a string - but its a date field. I'm baffled, I use a hosted version of this featureclass, and use Arcade to calculate this value using this approach which works fine.

var last_date = $feature.LastInsp;
var now = Today();
var DaysSince = round(DateDiff(now,last_date,'days'))

 

0 Kudos
1 Reply
RichardHowe
Occasional Contributor III

In field calculator your python expression would be something like:

int(str(datetime.today() - !LastInsp!).split(" ")[0])
0 Kudos