I am trying to exclude some results from numerous tables in an arc.sde database and the only field I can use is a date field. I have researche the Python2 site and tried to understand page 8.1 regarding datetime etc but not been able to achieve my goal yet. (Using Win 7, ArcGIS 10.2, Python 2.7.5 and mixed OS environment)
The code below runs fine.....
with arcpy.da.SearchCursor(fc, ['LASTEDIT_ON']) as cursor:
for row in cursor:
if row[0] <> None:
print str(row[0])
But I need it to exclude the rows returned where the hours/minutes/seconds are all 00:00:00.
2014-05-13 16:16:34
2014-09-26 11:45:15
2015-06-18 14:47:05
2015-02-03 10:38:50
2008-03-10 00:00:00
2007-06-06 00:00:00
I tried adding hour and minutes to my code but Im totally on the wrong track I think. Error as below.
if row[0] <> None and datetime.hour <> 0:
Error Info:
'module' object has no attribute 'hour'
If your date field is a real date field, not a text field, the following code will print the dates with hour, minute and second all null:
import arcpy
with arcpy.da.SearchCursor(fc, 'LASTEDIT_ON') as cursor:
for row in cursor:
if row[0].hour == 0:
if row[0].minute == 0:
if row[0].second == 0:
print row[0]