Hi, I am Calculating a Field with an Arcade Expression which compares the date in a given field with today’s date and provides a result in months. The result is calculated in to an existing field “Months at Current Stage”. I can run the Arcade Expression manually but I would like to automate this in Python. Is this possible in ArcGIS online Notebook using Python? New to Python, so any help would be appreciated!
Solved! Go to Solution.
You'll need to get familiar with the datetime module in python. Here are a couple of links to point you in the right direction:
https://www.kite.com/python/answers/how-to-get-the-number-of-months-between-two-dates-in-python
https://gist.github.com/amalgjose/c767a4846d6ecaa3b6d7
Mixing metaphors; Arcade and Python. I suggest just doing it all in python and run the script as scheduled task or as you suggest a notebook.
Joe,
Thanks for the response to my question. I gather from your reply that this would be possible in Python which is great.
While I have the following, very simple, Arcade Expression, my difficulty is how to write a Python script that would achieve the same result.
var startDate = Date($feature.Start_Date_of_Current_Stage);
var endDate = Date(Now());
var MACS = DateDiff(endDate, startDate, 'months');
return MACS;
I am completely new to Python and this will be my first Python script, so I appreciate the help.
Alen
You'll need to get familiar with the datetime module in python. Here are a couple of links to point you in the right direction:
https://www.kite.com/python/answers/how-to-get-the-number-of-months-between-two-dates-in-python
https://gist.github.com/amalgjose/c767a4846d6ecaa3b6d7
Thanks Joe,
Much appreciated. I will post my progress in the new year.