<?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: Notebook feature layer query date in where clause in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/notebook-feature-layer-query-date-in-where-clause/m-p/1605297#M64401</link>
    <description>&lt;P&gt;I think your outfields need to be a list and you may have to clean up your timestamp&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;now = datetime.datetime.now()
lastWeek = (now - datetime.timedelta(days = 7)).strftime("%Y-%m-%d %H:%M:%S")
out_fields = ['LOCID','ACTIVE','ADDRESS','LASTUPDATE']

query_string = f"LASTUPDATE &amp;gt;= TIMESTAMP  '{lastWeek}'"
query_result1 = addr_fl.query(where=query_string, out_fields=out_fields)&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 11 Apr 2025 17:41:08 GMT</pubDate>
    <dc:creator>JohnEvans6</dc:creator>
    <dc:date>2025-04-11T17:41:08Z</dc:date>
    <item>
      <title>Notebook feature layer query date in where clause</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/notebook-feature-layer-query-date-in-where-clause/m-p/1605013#M64396</link>
      <description>&lt;P&gt;Within AGOL Notebook I'm trying to query a date field in my feature layer and am having difficulty nailing down the correct syntax for the Where clause.&lt;/P&gt;&lt;P&gt;I'm trying to get all features that have been updated (edited) in the last week from the day the script is run.&lt;/P&gt;&lt;P&gt;Below is what I currently have in the Notebook cell for setting up the date variable (to be one week ago) and running the feature layer query code.&amp;nbsp; The code fails on the line with the query and I'm sure it has to do with the where clause.&amp;nbsp; "timestamp" was a recent addition and I definitely am not sure if it belongs in the clause.&lt;/P&gt;&lt;P&gt;I've verified that my lastWeek variable gets the correct date value.&lt;/P&gt;&lt;P&gt;&lt;FONT face="helvetica" size="2"&gt;now = datetime.datetime.now()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="helvetica" size="2"&gt;lastWeek = now - datetime.timedelta(days = 7)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="helvetica" size="2"&gt;query_result1 = addr_fl.query(where="LASTUPDATE &amp;gt;= timestamp 'lastWeek'", out_fields='LOCID,ACTIVE,ADDRESS,LASTUPDATE')&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Any help with this where clause syntax would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 22:49:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/notebook-feature-layer-query-date-in-where-clause/m-p/1605013#M64396</guid>
      <dc:creator>LeeBrannon1</dc:creator>
      <dc:date>2025-04-10T22:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook feature layer query date in where clause</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/notebook-feature-layer-query-date-in-where-clause/m-p/1605297#M64401</link>
      <description>&lt;P&gt;I think your outfields need to be a list and you may have to clean up your timestamp&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;now = datetime.datetime.now()
lastWeek = (now - datetime.timedelta(days = 7)).strftime("%Y-%m-%d %H:%M:%S")
out_fields = ['LOCID','ACTIVE','ADDRESS','LASTUPDATE']

query_string = f"LASTUPDATE &amp;gt;= TIMESTAMP  '{lastWeek}'"
query_result1 = addr_fl.query(where=query_string, out_fields=out_fields)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 11 Apr 2025 17:41:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/notebook-feature-layer-query-date-in-where-clause/m-p/1605297#M64401</guid>
      <dc:creator>JohnEvans6</dc:creator>
      <dc:date>2025-04-11T17:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook feature layer query date in where clause</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/notebook-feature-layer-query-date-in-where-clause/m-p/1605325#M64408</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp; The where clause in your code has my answer.&amp;nbsp; I neglected to put my variable in curly braces and I did not have the "f" at the front of my clause...that made the difference.&amp;nbsp; My out_fields were ok though.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 19:45:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/notebook-feature-layer-query-date-in-where-clause/m-p/1605325#M64408</guid>
      <dc:creator>LeeBrannon1</dc:creator>
      <dc:date>2025-04-11T19:45:58Z</dc:date>
    </item>
  </channel>
</rss>

