<?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: Create layer of records with Max Date in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/create-layer-of-records-with-max-date/m-p/67617#M5540</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For some reason the other thread was mistakenly merged with a completely different thread. Here is the answer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/90090-List-Broken-Data-Source-s-Path?p=319943&amp;amp;viewfull=1#post319943"&gt;http://forums.arcgis.com/threads/90090-List-Broken-Data-Source-s-Path?p=319943&amp;amp;viewfull=1#post319943&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Aug 2013 22:48:11 GMT</pubDate>
    <dc:creator>StacyRendall1</dc:creator>
    <dc:date>2013-08-12T22:48:11Z</dc:date>
    <item>
      <title>Create layer of records with Max Date</title>
      <link>https://community.esri.com/t5/python-questions/create-layer-of-records-with-max-date/m-p/67615#M5538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;New at Python - appreciate assistance pointing me in the right direction. Using version 10.1 - not SDE environment I need to group an attribute table of inspection data and only select the most recent date. The python script below does not provide the data I need. It executes and creates a layer but it has the same records as if I didn't run the script. Example if I have 5 records for ID 100 I only want to return the record with the most recent date. I have roughly 500 firehyrdrants and want to only select the distinct hydrant ID and then the most recent inspection date.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy
from arcpy import env
env.workspace=r"Z:\GIS_Data\gdb\GIS_Test.gdb"

fc="COA_FH_Inspections"
cursor = arcpy.UpdateCursor(fc)
idlist = []
datelist = []

for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; idlist.append(row.getValue('HydrID'))
&amp;nbsp;&amp;nbsp;&amp;nbsp; datelist.append(row.getValue('TestDate'))
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)

print idlist
print datelist

idunique = set(idlist)

#Make a layer from the feature class
arcpy.MakeFeatureLayer_management(fc, "lyr")

for i in idunique:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if i == idlist:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management("lyr", "New_Selection", '"HydrID" = i')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management("lyr", "subset_Selection",'"TestDate" = (Select Max("TestDate") from "lyr"')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 13:29:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-layer-of-records-with-max-date/m-p/67615#M5538</guid>
      <dc:creator>TerryHiggins1</dc:creator>
      <dc:date>2013-08-08T13:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create layer of records with Max Date</title>
      <link>https://community.esri.com/t5/python-questions/create-layer-of-records-with-max-date/m-p/67616#M5539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have posted this question twice. I have posted the answer on your other thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/90182-Max-Date-How-to-return-unique-IDs-with-Max-Date"&gt;http://forums.arcgis.com/threads/90182-Max-Date-How-to-return-unique-IDs-with-Max-Date&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 00:19:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-layer-of-records-with-max-date/m-p/67616#M5539</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2013-08-09T00:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create layer of records with Max Date</title>
      <link>https://community.esri.com/t5/python-questions/create-layer-of-records-with-max-date/m-p/67617#M5540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For some reason the other thread was mistakenly merged with a completely different thread. Here is the answer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/90090-List-Broken-Data-Source-s-Path?p=319943&amp;amp;viewfull=1#post319943"&gt;http://forums.arcgis.com/threads/90090-List-Broken-Data-Source-s-Path?p=319943&amp;amp;viewfull=1#post319943&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2013 22:48:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-layer-of-records-with-max-date/m-p/67617#M5540</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2013-08-12T22:48:11Z</dc:date>
    </item>
  </channel>
</rss>

