AnsweredAssumed Answered

Delete features based on Date using Python

Question asked by rus5 on Nov 6, 2014
Latest reply on Nov 6, 2014 by xander_bakker


We have some feature classes stored in a feature dataset in ArcSDE . I want to delete the features which are older than 10 years from the feature classes using a python script.

Every feature class has an attribute field "LAST EDITED ON". The sample value is in format "10/14/2014 1:31:52 AM".


Note: The features which are older than 10 years should be deleted from every feature class on daily basis (If there are any).

We are using ArcGIS version 10.1


I have created following expression which selects the features for deletion.


expression = long(float((arcpy.CalculateValue_management(time.mktime(([0])) - long(float((arcpy.CalculateValue_management(time.mktime(time.strptime(!LAST_EDITED_ON!, "%x %X"))))[0])) > 0


The expression runs fine on Python window but gives an error while running as a tool.


SyntaxError: invalid syntax (, line 18)

Failed to execute (Script).


Line 18 is the expression seen above.


Please suggest how to solve this problem.



Any help will be appreciated.