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?
Solved! Go to Solution.
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)
>>>
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
>>>
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:
And the Data Last Updated date:
And the script output, which shows the modified/updated date, not the Data Last Updated date:
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)
>>>
Excellent, that does exactly what I was looking for. Thanks Joshua.
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.
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.
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.
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."
Yep. Nevertheless, your solution still solves my particular use case and is much appreciated.