Select to view content in your preferred language

Make feature layer based off last edited date

06-24-2019 01:38 PM
New Contributor III

I have editor tracking enabled on a feature class, and need to calculate some fields within a polygon that are edited each day. I currently have a script that will calculate the fields for all of the features within the polygon, but there are thousands of features and I only need to calculate the ones that were edited each day. My issue is creating a feature layer with a where clause for only today's features. What's strange is that it will work using the python window within ArcMap, but won't work as a standalone script. The layer created just contains all of the features...

arcpy.MakeFeatureLayer_management(meters, 'meter_layer', "'last_edited_date' >= 'DATEADD(d, 0, DATEDIFF(d, 0, GETDATE()))'", "", "")

Any help would be greatly appreciated

0 Kudos
1 Reply
Occasional Contributor II

I have had this problem as well. I make a feature layer without a definition query, then use the feature layer and use the Select by Attributes tool is where I put in the date query, then calculate field. 

0 Kudos