Select to view content in your preferred language

Programmatic access to 'Data Last Updated' value in ArcGIS Online

7074
11
Jump to solution
09-05-2020 01:13 PM
JosephRhodes2
Frequent Contributor

Is there any way to programmatically access the 'Data Last Updated' value on the ArcGIS Online Item Details page, e.g., through the Python API? If not, are there any plans to make it available?

AGOL screenshot

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

I am fairly sure that is a dynamically generated date based on the maximum value of last edit dates for all of layers and tables that make up the feature service:

>>> id = # id of the item to retrieve
>>> item = gis.content.get(id)
>>> data_modified = max(
...     i.properties.editingInfo.lastEditDate
...     for i
...     in item.layers + item.tables
... )
>>> datetime.datetime.fromtimestamp(data_modified/1000)
datetime.datetime(2020, 9, 6, 9, 31, 46, 299000)
>>> 

View solution in original post

11 Replies
JoshuaBixby
MVP Esteemed Contributor

Use the modified property of the item:

>>> id = # id of the item to retrieve
>>> item = gis.content.get(id)
>>> datetime.datetime.fromtimestamp(item.modified/1000)
datetime.datetime(2019, 6, 17, 17, 1, 50) # Last Updated date
>>>
0 Kudos
JosephRhodes2
Frequent Contributor

Hey Joshua,

Unfortunately this only gives the Modified Date, i.e., the date item details were changed (tags, title, etc.), not the date the data was last changed. The below screenshots are all for the same item.

Here's the modified/updated date:

ss

And the Data Last Updated date:
dd

And the script output, which shows the modified/updated date, not the Data Last Updated date:

sa

JoshuaBixby
MVP Esteemed Contributor

I am fairly sure that is a dynamically generated date based on the maximum value of last edit dates for all of layers and tables that make up the feature service:

>>> id = # id of the item to retrieve
>>> item = gis.content.get(id)
>>> data_modified = max(
...     i.properties.editingInfo.lastEditDate
...     for i
...     in item.layers + item.tables
... )
>>> datetime.datetime.fromtimestamp(data_modified/1000)
datetime.datetime(2020, 9, 6, 9, 31, 46, 299000)
>>> 
JosephRhodes2
Frequent Contributor

Excellent, that does exactly what I was looking for. Thanks Joshua.

0 Kudos
JosephRhodes2
Frequent Contributor

I'll just add that this date is apparently also updated any time a setting/capability is updated. Sync, extract, editing, etc. Which is unfortunate - it would be nice to have access to a date that always reflected the last time the data itself changed. I doubt that's possible without querying features on an editor tracking-enabled service.

JoshuaBixby
MVP Esteemed Contributor

Joseph, can you elaborate on the extract you are doing that is modifying the data last updated date?  From what I recall, exporting data or calling Extract Data—ArcGIS REST API: Spatial Analysis Service | ArcGIS for Developers  doesn't alter that date.

0 Kudos
JosephRhodes2
Frequent Contributor

Joshua, I was saying that when you update any setting (either on the Settings tab or programmatically), this date is updated. So if you enable/disable sync, enable/disable editing, enable/disable editor tracking, enable/disable extract,etc., it updates that date. 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Joseph, I see what you are saying now.  Given that enabling/disabling editing, extract, etc... doesn't actually change data, I do think this is an Esri #fail.  There really isn't any reason to update the lastEditDate of a layer if the feature service is reconfigured, e.g., to enable/disable editing.  If Esri does want to go down that path, the labels for those dates should not be "Data Last Updated."

JosephRhodes2
Frequent Contributor

Yep. Nevertheless, your solution still solves my particular use case and is much appreciated.

0 Kudos