<?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 Select records based on two dates in Python from Arcgis Online in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/select-records-based-on-two-dates-in-python-from/m-p/1242674#M8189</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How do I Pull the data based on two dates in Python from ArcGIS Online?&lt;/P&gt;&lt;P&gt;The below code works for single date:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;feature_layer_id = ''&lt;/P&gt;&lt;P&gt;Inspform = gis.content.get(feature_layer_id)&lt;/P&gt;&lt;P&gt;from datetime import datetime, timedelta&lt;BR /&gt;insp=Inspform.layers[0].query().sdf #.sdf get as a pandas dataframe&lt;BR /&gt;last_24hour_date_time = datetime.now() - timedelta(hours = 3200)&amp;nbsp;&lt;BR /&gt;timestamp = last_24hour_date_time.strftime('%Y-%m-%d %H:%M:%S')&lt;BR /&gt;filterinsp = insp[insp['CreationDate'] &amp;gt;= timestamp]&lt;BR /&gt;sinsp = filterinsp.astype({"SHAPE":str}) #should convert else error&lt;BR /&gt;sinsp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to add another date to compare, the below code doesn't work: It says invalid syntax at OR&lt;/P&gt;&lt;P&gt;from datetime import datetime, timedelta&lt;BR /&gt;insp=Inspform.layers[0].query().sdf #.sdf get as a pandas dataframe&lt;BR /&gt;last_24hour_date_time = datetime.now() - timedelta(hours = &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; #replace it with 24 hours and use append ,3200&lt;BR /&gt;timestamp = last_24hour_date_time.strftime('%Y-%m-%d %H:%M:%S')&lt;BR /&gt;filterinsp = insp [ [insp['CreationDate'] &amp;gt;= timestamp] OR [insp['EditDate'] &amp;gt;= timestamp] ]&lt;BR /&gt;sinsp = filterinsp.astype({"SHAPE":str}) #should convert else error&lt;BR /&gt;sinsp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2022 14:42:22 GMT</pubDate>
    <dc:creator>ChallagundlaSindhuraITS</dc:creator>
    <dc:date>2022-12-20T14:42:22Z</dc:date>
    <item>
      <title>Select records based on two dates in Python from Arcgis Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/select-records-based-on-two-dates-in-python-from/m-p/1242674#M8189</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How do I Pull the data based on two dates in Python from ArcGIS Online?&lt;/P&gt;&lt;P&gt;The below code works for single date:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;feature_layer_id = ''&lt;/P&gt;&lt;P&gt;Inspform = gis.content.get(feature_layer_id)&lt;/P&gt;&lt;P&gt;from datetime import datetime, timedelta&lt;BR /&gt;insp=Inspform.layers[0].query().sdf #.sdf get as a pandas dataframe&lt;BR /&gt;last_24hour_date_time = datetime.now() - timedelta(hours = 3200)&amp;nbsp;&lt;BR /&gt;timestamp = last_24hour_date_time.strftime('%Y-%m-%d %H:%M:%S')&lt;BR /&gt;filterinsp = insp[insp['CreationDate'] &amp;gt;= timestamp]&lt;BR /&gt;sinsp = filterinsp.astype({"SHAPE":str}) #should convert else error&lt;BR /&gt;sinsp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to add another date to compare, the below code doesn't work: It says invalid syntax at OR&lt;/P&gt;&lt;P&gt;from datetime import datetime, timedelta&lt;BR /&gt;insp=Inspform.layers[0].query().sdf #.sdf get as a pandas dataframe&lt;BR /&gt;last_24hour_date_time = datetime.now() - timedelta(hours = &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; #replace it with 24 hours and use append ,3200&lt;BR /&gt;timestamp = last_24hour_date_time.strftime('%Y-%m-%d %H:%M:%S')&lt;BR /&gt;filterinsp = insp [ [insp['CreationDate'] &amp;gt;= timestamp] OR [insp['EditDate'] &amp;gt;= timestamp] ]&lt;BR /&gt;sinsp = filterinsp.astype({"SHAPE":str}) #should convert else error&lt;BR /&gt;sinsp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 14:42:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/select-records-based-on-two-dates-in-python-from/m-p/1242674#M8189</guid>
      <dc:creator>ChallagundlaSindhuraITS</dc:creator>
      <dc:date>2022-12-20T14:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select records based on two dates in Python from Arcgis Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/select-records-based-on-two-dates-in-python-from/m-p/1242681#M8190</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank" rel="noopener"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;will get rid of that cool emoji in your code and provide line numbers to help others&lt;/P&gt;&lt;P&gt;Are you sure OR isn't lowercase (eg. or )&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 15:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/select-records-based-on-two-dates-in-python-from/m-p/1242681#M8190</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-12-20T15:03:45Z</dc:date>
    </item>
  </channel>
</rss>

