<?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: Retrieve Unique Dates From Attribute Field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/retrieve-unique-dates-from-attribute-field/m-p/659416#M51262</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;formatteddatetime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; yourdatevalue&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y/%m/%d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Oct 2017 20:06:29 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2017-10-18T20:06:29Z</dc:date>
    <item>
      <title>Retrieve Unique Dates From Attribute Field</title>
      <link>https://community.esri.com/t5/python-questions/retrieve-unique-dates-from-attribute-field/m-p/659415#M51261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to pull all of the unique dates out of an attribute field and I'm having issues formatting the output. Right now I have the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table = r"C:\Temp\SomeFile.shp"&lt;BR /&gt;field = "ADD_DATE"&lt;BR /&gt;valueList = []&lt;BR /&gt;rows = arcpy.SearchCursor(table)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for row in rows:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;valueList.append(row.getValue(field))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uniqueSet = set(valueList)&lt;BR /&gt;uniqueList = list(uniqueSet)&lt;BR /&gt;uniqueList.sort()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;del rows&lt;BR /&gt;del row&lt;/P&gt;&lt;P&gt;print uniqueList&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is&amp;nbsp;&lt;STRONG&gt;datetime.datetime(2017, 9, 19, 14, 28, 29)&lt;/STRONG&gt; I'd like it to simply be &lt;STRONG&gt;2017/09/19&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Oct 2017 19:59:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/retrieve-unique-dates-from-attribute-field/m-p/659415#M51261</guid>
      <dc:creator>MikeEdwards</dc:creator>
      <dc:date>2017-10-18T19:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Dates From Attribute Field</title>
      <link>https://community.esri.com/t5/python-questions/retrieve-unique-dates-from-attribute-field/m-p/659416#M51262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;formatteddatetime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; yourdatevalue&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y/%m/%d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Oct 2017 20:06:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/retrieve-unique-dates-from-attribute-field/m-p/659416#M51262</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-10-18T20:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Dates From Attribute Field</title>
      <link>https://community.esri.com/t5/python-questions/retrieve-unique-dates-from-attribute-field/m-p/659417#M51263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will want to use the newer Data Access cursors:&amp;nbsp; &lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/searchcursor-class.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/searchcursor-class.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;SearchCursor—Help | ArcGIS Desktop&lt;/A&gt;.&amp;nbsp; Python's &lt;A href="https://docs.python.org/2/library/collections.html#collections.Counter" rel="nofollow noopener noreferrer" target="_blank"&gt;Counter class &lt;/A&gt;was specifically made for situations like this.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; collections &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; Counter

table &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\Temp\SomeFile.shp"&lt;/SPAN&gt;
field &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ADD_DATE"&lt;/SPAN&gt;

cnt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Counter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dt &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; dt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;table&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; dt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; freq &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cnt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; dt&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; dt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y/%m/%d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/retrieve-unique-dates-from-attribute-field/m-p/659417#M51263</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T03:53:58Z</dc:date>
    </item>
  </channel>
</rss>

