<?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: Use only date from Datetime in arcpy.SelectLayerByAttribute_management in ArcMap Questions</title>
    <link>https://community.esri.com/t5/arcmap-questions/use-only-date-from-datetime-in-arcpy/m-p/1336407#M4642</link>
    <description>&lt;P&gt;Hello Kara,&lt;/P&gt;&lt;P&gt;Here is a code snippet that leads to the arcPy.SelectLayerAttribute_Management&lt;/P&gt;&lt;DIV&gt;fds = arcpy.ListDatasets(feature_type='Feature')&lt;/DIV&gt;&lt;DIV&gt;for fd in fds:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; # For each feature dataset, get a list of feature classes.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; fcs = arcpy.ListFeatureClasses(feature_dataset=fd)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; for fc in fcs:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print ('Database: ' + fd + ' Feature Class: ' + fc)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lstFields = arcpy.ListFields(fc)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; field_names = [f.name.upper() for f in lstFields]&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if "ADMIN_DATE" in field_names:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # chgdate &amp;gt; admin_date.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SetQuery = 'chgdate &amp;gt; admin_date'&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.MakeFeatureLayer_management(fc, fc + "_new")&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # print(fc+"_New")&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.SelectLayerByAttribute_management(fc + "_new", 'NEW_SELECTION', SetQuery)&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I hope this helps to compliment my original post.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;-Jeff&lt;/SPAN&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 09 Oct 2023 20:43:08 GMT</pubDate>
    <dc:creator>JeffHouser</dc:creator>
    <dc:date>2023-10-09T20:43:08Z</dc:date>
    <item>
      <title>Use only date from Datetime in arcpy.SelectLayerByAttribute_management</title>
      <link>https://community.esri.com/t5/arcmap-questions/use-only-date-from-datetime-in-arcpy/m-p/1336391#M4640</link>
      <description>&lt;P&gt;I'm defining a SetQuery variable in Arcpy.SelectLayerByAttribute_management(fc, 'NEW_SELECTION', SetQuery) as&amp;nbsp;&lt;/P&gt;&lt;P&gt;SetQuery = 'chgdate &amp;gt; admin_date'.&amp;nbsp; Both chgdate and admin_date are fields in the featureclass.&amp;nbsp; However, the chgdate is datetime, and admin_date is date fieldtype.&amp;nbsp; For the results from the&amp;nbsp;Arcpy.SelectLayerByAttribute_management, I would like the SetQuery be based on where the chgdate values are of the date field type (not include time).&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this?&lt;/P&gt;&lt;P&gt;-Jeff&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 19:09:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/use-only-date-from-datetime-in-arcpy/m-p/1336391#M4640</guid>
      <dc:creator>JeffHouser</dc:creator>
      <dc:date>2023-10-09T19:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Use only date from Datetime in arcpy.SelectLayerByAttribute_management</title>
      <link>https://community.esri.com/t5/arcmap-questions/use-only-date-from-datetime-in-arcpy/m-p/1336404#M4641</link>
      <description>&lt;P&gt;How are you processing your data?&amp;nbsp; Can you post a Python snippet or something?&amp;nbsp; When I need a portion of a date, I parse it using the pandas package and select the portion of the date I need &amp;amp; store that as a new variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I do that, I use a method &lt;A href="https://stackoverflow.com/questions/16176996/keep-only-date-part-when-using-pandas-to-datetime" target="_self"&gt;like this article describes&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 20:33:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/use-only-date-from-datetime-in-arcpy/m-p/1336404#M4641</guid>
      <dc:creator>Kara_Shindle</dc:creator>
      <dc:date>2023-10-09T20:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use only date from Datetime in arcpy.SelectLayerByAttribute_management</title>
      <link>https://community.esri.com/t5/arcmap-questions/use-only-date-from-datetime-in-arcpy/m-p/1336407#M4642</link>
      <description>&lt;P&gt;Hello Kara,&lt;/P&gt;&lt;P&gt;Here is a code snippet that leads to the arcPy.SelectLayerAttribute_Management&lt;/P&gt;&lt;DIV&gt;fds = arcpy.ListDatasets(feature_type='Feature')&lt;/DIV&gt;&lt;DIV&gt;for fd in fds:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; # For each feature dataset, get a list of feature classes.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; fcs = arcpy.ListFeatureClasses(feature_dataset=fd)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; for fc in fcs:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print ('Database: ' + fd + ' Feature Class: ' + fc)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lstFields = arcpy.ListFields(fc)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; field_names = [f.name.upper() for f in lstFields]&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if "ADMIN_DATE" in field_names:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # chgdate &amp;gt; admin_date.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SetQuery = 'chgdate &amp;gt; admin_date'&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.MakeFeatureLayer_management(fc, fc + "_new")&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # print(fc+"_New")&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.SelectLayerByAttribute_management(fc + "_new", 'NEW_SELECTION', SetQuery)&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I hope this helps to compliment my original post.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;-Jeff&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 09 Oct 2023 20:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/use-only-date-from-datetime-in-arcpy/m-p/1336407#M4642</guid>
      <dc:creator>JeffHouser</dc:creator>
      <dc:date>2023-10-09T20:43:08Z</dc:date>
    </item>
  </channel>
</rss>

