ArcPy – How to Get the ‘Modified’ Date for a FeatureClass in a File Geodatabase

arcgis-10.2arcpyfeature-classfile-geodatabase

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?

Best Answer

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      
    GetStandaloneModules()      
    InitStandalone()      
    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)  
Related Question