Select to view content in your preferred language

Auto update a field based on current date

1953
3
08-27-2021 07:55 AM
bikeMapper312
Emerging Contributor

I have a shapefile of about 175 points that correspond to projects. Each project has a "contract deadline" field and a "months until deadline" field (see attached screenshot).

I want the "months until deadline" field to automatically update over time based off the date. 

For example, a deadline of 12/31/2021 would have 4 "months until deadline" as of August 31. Instead of having to manually updated this every month, I'd like Arc to update automatically based on the current day of the year. 

Any way to do this or tips of how to do this?

The end product will be a map of my points that show the points with a range of colors displaying the "months until deadline" field.

Thanks!

Rd529_0-1630076295159.png

 

 

0 Kudos
3 Replies
Robert_LeClair
Esri Notable Contributor

One way that I think you could automate this is create a Model in Modelbuilder that does the GP work on the shapefile. Then export it out as a Python script and associate the Python script with Windows Task Scheduler so it runs every day.  For example the Arcade expression I used in the screen grab does the month calculation for the difference between Contract Deadline and Months Until Deadline.  
DateDiff.JPG

0 Kudos
bikeMapper312
Emerging Contributor

Thanks for the reply. I think i sort of got it to work..? 

Rd529_0-1630079167150.png

 I could calculate TimeDiff between Todays date and the "Contract Deadline", but now the goal is for that "Today" field to update essentially everyday or week. It wouldn't be horribly annoying to recaculate manually once in awhile but would prefer it auto calculates. 

This map is in arcpro right now but will go on ArcGIS Online, is that function available on ArcGIS Online
?

Cheers

0 Kudos
Robert_LeClair
Esri Notable Contributor

One thing you can do is change the Field Type from a Float/Double to a Short Integer.  That way you get whole months vs. something like 4.112131 as a value.  It would then be 3 or 4 or 8.  The automation part is probably best done using Python via Windows Task Scheduler so it does it automatically at a certain date/time.

Arcade is a platform wide expression language so that calculation will work in ArcGIS Online as well.  If you're sharing the shapefile out as a web layer, you can overwrite the web layer from ArcGIS Pro every week if desired and any web maps/apps pointing to that web layer would update.

0 Kudos