There is a closed question which is similar to or identical to this question: Getting date modified for a feature class within a file geodatabase via arcpy

Looking at a file geodatabase featureclass in ArcCatalog, there is a Modified attribute showing the date that the featureclass was last changed:

enter image description here

This is not the same as the Modified date for its parent file geodatabase (which means that I can't obtain the featureclass 'modified' value via the operating system):

enter image description here

I'm limited to using the older ArcMap/ArcCatalog version of ArcPy, and I can't see where to find the 'modified on' date in the documentation, eg http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/featureclass-properties.htm

How can I access the Modified date via ArcPy?


This is not possible with ArcPy. To access this property, you need to use ArcObjects. You can do this from python via comtypes.

The following example is from mbabinski1988 on Geonet

First set up comtypes and snippets.py:

Then the following function can be used to return modified time:

def GetModifiedDate(gdb, tableName):    
    #  https://community.esri.com/thread/74409#comment-453427

    # Setup      
    import comtypes.gen.esriSystem as esriSystem      
    import comtypes.gen.esriGeoDatabase as esriGeoDatabase      
    import comtypes.gen.esriDataSourcesGDB as esriDataSourcesGDB      

    # Open the FGDB      
    pWS = Standalone_OpenFileGDB(gdb)    

    # Create empty Properties Set      
    pPropSet = NewObj(esriSystem.PropertySet, esriSystem.IPropertySet)      
    pPropSet.SetProperty("database", gdb)      

    # Cast the FGDB as IFeatureWorkspace      
    pFW = CType(pWS, esriGeoDatabase.IFeatureWorkspace)      

    # Open the table      
    pTab = pFW.OpenTable(tableName)      

    # Cast the table as a IDatasetFileStat      
    pDFS = CType(pTab, esriGeoDatabase.IDatasetFileStat)      

    # Get the date modified      
    return pDFS.StatTime(2)  
  • Does another version of snippets.py exist for 10.3 and beyond?
    – Nick
    Aug 4 '20 at 3:53
  • @Nick Nope. For 10.3 I just changed line 20 from keyESRI = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\ESRI\\Desktop10.2") to keyESRI = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\ESRI\\Desktop10.3"). Should work for >10.3 as well, just change to the appropriate version.
    – user2856
    Aug 4 '20 at 5:44
  • Thanks, I tried the same (I think there may have been one additional instance in snippets.py I changed as well) but still got some errors ... I think something is wrong with how my registry because I also had to change HKEY_LOCAL_MACHINE to HKEY_USER_CURRENT
    – Nick
    Aug 4 '20 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.