I am trying to iterate through each date in a shapefile using a list of dates. I am having trouble phrasing my Where clause to select only one date. If I use the following Python code, all dates are selected in each iteration:
datelst = ['2002-06-06','2002-06-07','2002-06-08']
arcpy.MakeFeatureLayer_management ("E:/hotspots.shp", "hotspots")
for dat in datelst:
arcpy.SelectLayerByAttribute_management ("hotspots", "NEW_SELECTION", ("'date' = 'dat'"))
I have tried rephrasing the Where clause in many different ways, but the result is that all records are selected, no records are selected, or an error message is returned. The query is successful if I use the string itself (e.g.
arcpy.SelectLayerByAttribute_management ("hotspots", "NEW_SELECTION", "date = '2002-06-06'")
but then it is not possible to iterate through all of the dates in the file.