MikeEdwards

Selecting Features by Date

Discussion created by MikeEdwards on Nov 13, 2017
Latest reply on Nov 14, 2017 by MikeEdwards

I'm trying to select all the features in a feature class that have been edited in the past day. I'm using SelectLayerByAttribute_management and I keep getting an error on the SQL query and was hoping someone could give me a hand.

In the code below lyr is the feature class being evaluated and MOD_DATE is the date field being checked.

yesterday = date.today() - timedelta(1)
yesterdaysDate = yesterday.strftime("%m/%d/%y %I:%M:%S")

SQL_statement = "MOD_DATE >= 'yesterdaysDate'"
arcpy.MakeFeatureLayer_management(lyr, "FEATURE_SELECTION")
arcpy.SelectLayerByAttribute_management("FEATURE_SELECTION", "NEW_SELECTION", SQL_statement)

Outcomes