AnsweredAssumed Answered

querry always returns ZERO results, using date type

Question asked by armein01 on May 19, 2014
Latest reply on May 19, 2014 by armein01
Hello,
Still working with a grid, trying to count the number of negative s after the first positive.
Everything seems to be working as expected, except my count is always zero.

Sample output:
[datetime.datetime(2009, 3, 24, 0, 0), datetime.datetime(2009, 3, 24, 0, 0), datetime.datetime(2010, 3, 31, 0, 0), datetime.datetime(2010, 3, 31, 0, 0), datetime.datetime(2011, 3, 22, 0, 0)]
2009-03-24 00:00:00
0
[datetime.datetime(2007, 11, 19, 0, 0)]
2007-11-19 00:00:00
0
[datetime.datetime(2008, 4, 2, 0, 0), datetime.datetime(2010, 4, 14, 0, 0)]
2008-04-02 00:00:00
0
[datetime.datetime(2005, 9, 14, 0, 0), datetime.datetime(2006, 3, 31, 0, 0), datetime.datetime(2006, 4, 12, 0, 0), datetime.datetime(2010, 4, 1, 0, 0), datetime.datetime(2010, 4, 1, 0, 0), datetime.datetime(2011, 3, 22, 0, 0), datetime.datetime(2011, 3, 22, 0, 0), datetime.datetime(2011, 3, 25, 0, 0), datetime.datetime(2011, 4, 13, 0, 0), datetime.datetime(2011, 4, 14, 0, 0)]
2005-09-14 00:00:00
0
[datetime.datetime(2011, 4, 14, 0, 0)]
2011-04-14 00:00:00
0


[CODE]
for grid in grids:
        dates = []
        arcpy.SelectLayerByLocation_management("cwdpts4Anlys", "WITHIN", grid.shape, "", "NEW_SELECTION")
        positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_DATE" )

        for positive in positives:
            dates.append(positive.SAMPLE_DATE)
        print dates
       
        earliest = min(dates)
        print earliest
        arcpy.SelectLayerByLocation_management("cwdpts4Anlys", "WITHIN", grid.shape,"", "NEW_SELECTION")
        arcpy.SelectLayerByAttribute_management("cwdpts4Anlys", "SUBSET_SELECTION", ' "ELISALYMPHNODE" = \'Negative\' ')
        arcpy.SelectLayerByAttribute_management("cwdpts4Anlys","SUBSET_SELECTION",'"SAMPLE_DATE" <= date.earliest ' )
        result = int(arcpy.GetCount_management("cwdpts4Anlys").getOutput(0))
        print result
[\Code]


I have tried several different formats in the SelectLayerByAttribute line including .....date earliest   and........ earliest, but the return is always the same.

thanks again
Alicia

Outcomes