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 <SPAN class="operator token">=</SPAN> date<SPAN class="punctuation token">.</SPAN>today<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> timedelta<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
yesterdaysDate <SPAN class="operator token">=</SPAN> yesterday<SPAN class="punctuation token">.</SPAN>strftime<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"%m/%d/%y %I:%M:%S"</SPAN><SPAN class="punctuation token">)</SPAN>
SQL_statement <SPAN class="operator token">=</SPAN> <SPAN class="string token">"MOD_DATE >= 'yesterdaysDate'"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"FEATURE_SELECTION"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"FEATURE_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NEW_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN> SQL_statement<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>