<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Search Cursor against date field and using date with python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25967#M1942</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ')

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you have an extra single quote at the end.&amp;nbsp; You single quote for the expression ends at the end of the 2nd parameter, then I see no single quote for the one on the end to go with.&amp;nbsp; SHould be like this I believe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" )

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And yes, syntax errors are the devil.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 21:02:59 GMT</pubDate>
    <dc:creator>IanMurray</dc:creator>
    <dc:date>2021-12-10T21:02:59Z</dc:date>
    <item>
      <title>Search Cursor against date field and using date with python</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25965#M1940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good Afternoon ArcPy Wizards!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would love some input on my code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to capture the earliest positive in a grid and then count&amp;nbsp; the negative sample that were required before the positive.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; for grid in grids: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dates = [] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("cwdpts4Anlys", "WITHIN", grid.shape, "NEW_SELECTION") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ')&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for positive in positives: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dates.append(row[0]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; earliest = min(dates) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("cwdpts4Anlys", "WITHIN", grid.shape, "NEW_SELECTION") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management("cwdpts4Anlys", "SUBSET_SELECTION", ' "ELISALYMPHNODE" = \'Negative\' ') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management("cwdpts4Anlys","SUBSET_SELECTION",'"SAMPLE_DATE" &amp;lt;= date earliest ' ) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; negatives = int(arcpy.GetCount_management("cwdpts4Anlys").getOutput(0)) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grid.setValue('NegPrior2Pos', negatives) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grids.updateRow(grid) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I get a syntax error at &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ive tried adding the keyword date before "SAMPLE_DATE" and many other ways.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Alicia&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 19:23:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25965#M1940</guid>
      <dc:creator>AliciaMein</dc:creator>
      <dc:date>2014-05-16T19:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Search Cursor against date field and using date with python</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25966#M1941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="plain" name="code"&gt; positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ' &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just a quick note: you have it as "SAMPLE_ DATE", not "SAMPLE_DATE".&amp;nbsp; It could just be a copy/paste into the forum post editor, but you may want to take a quick look at your source code to verify this isn't the problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 19:28:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25966#M1941</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-05-16T19:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Search Cursor against date field and using date with python</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25967#M1942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ')

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you have an extra single quote at the end.&amp;nbsp; You single quote for the expression ends at the end of the 2nd parameter, then I see no single quote for the one on the end to go with.&amp;nbsp; SHould be like this I believe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" )

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And yes, syntax errors are the devil.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:02:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25967#M1942</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2021-12-10T21:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Search Cursor against date field and using date with python</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25968#M1943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" '

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Just a quick note: you have it as "SAMPLE_ DATE", not "SAMPLE_DATE".&amp;nbsp; It could just be a copy/paste into the forum post editor, but you may want to take a quick look at your source code to verify this isn't the problem.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think your right, but I am also curious about how the date format is maintained.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; When I set up the "dates" list, what is the format of the list?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Alicia&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:03:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25968#M1943</guid>
      <dc:creator>AliciaMein</dc:creator>
      <dc:date>2021-12-10T21:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Search Cursor against date field and using date with python</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25969#M1944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" ')

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I think you have an extra single quote at the end.&amp;nbsp; You single quote for the expression ends at the end of the 2nd parameter, then I see no single quote for the one on the end to go with.&amp;nbsp; SHould be like this I believe.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

positives = arcpy.SearchCursor("cwdpts4Anlys",' "ELISALYMPHNODE" = \'Positive\' ' , "", "SAMPLE_ DATE" )

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;And yes, syntax errors are the devil.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I missed that! Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:03:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-against-date-field-and-using-date/m-p/25969#M1944</guid>
      <dc:creator>AliciaMein</dc:creator>
      <dc:date>2021-12-10T21:03:04Z</dc:date>
    </item>
  </channel>
</rss>

