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((datetime.datetime.now()+relativedelta(years=-10)).timetuple()))))) - long(float((arcpy.CalculateValue_management(time.mktime(time.strptime(!LAST_EDITED_ON!, "%x %X")))))) > 0
The expression runs fine on Python window but gives an error while running as a tool.
SyntaxError: invalid syntax (DeleteFeatureScript_Latest.py, 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.