<?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: Python API query string in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782244#M1250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if you use .format() ?&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;queryString1&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Survey_Start&amp;gt;{}'.format(&lt;/SPAN&gt;&lt;SPAN style="color: #4ec9b0;"&gt;str&lt;/SPAN&gt;&lt;SPAN&gt;(timeDifference))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Nov 2019 14:05:30 GMT</pubDate>
    <dc:creator>JohannesBierer</dc:creator>
    <dc:date>2019-11-11T14:05:30Z</dc:date>
    <item>
      <title>Python API query string</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782243#M1249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to use the Python API in a regularly scheduled script to query data from a table, I'd like to query the weeks data for processing. I can query any non date field just fine, but whenever I try to query a date field I get either a 'where' parameter invalid or "Unable to perform query. Please check your parameters." Below is the code, I have also tried numerous different date formats, but to no avail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;timeDifference&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;datetime.datetime.now()&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;datetime.timedelta(&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;days&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #b5cea8;"&gt;7&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV style="background-color: #1e1e1e; font-weight: normal;"&gt;&lt;DIV&gt;&lt;SPAN&gt;queryString1&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Survey_Start&amp;gt;'&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #4ec9b0;"&gt;str&lt;/SPAN&gt;&lt;SPAN&gt;(timeDifference)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV style="background-color: #1e1e1e; font-weight: normal;"&gt;&lt;DIV&gt;&lt;SPAN&gt;query1Result&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;table.query(&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;where&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;queryString1,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;out_fields&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Project'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 13:44:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782243#M1249</guid>
      <dc:creator>GrantHaynes</dc:creator>
      <dc:date>2019-11-11T13:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python API query string</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782244#M1250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if you use .format() ?&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;queryString1&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Survey_Start&amp;gt;{}'.format(&lt;/SPAN&gt;&lt;SPAN style="color: #4ec9b0;"&gt;str&lt;/SPAN&gt;&lt;SPAN&gt;(timeDifference))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 14:05:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782244#M1250</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2019-11-11T14:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python API query string</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782245#M1251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't have to str objects prior to using python 'format' or f strings&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="string token"&gt;"{} - {} = {} "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="string token"&gt;'2 - 1 = 1 '&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:53:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782245#M1251</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T08:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Python API query string</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782246#M1252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It still fails&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;timeDifference&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;datetime.datetime.now()&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;datetime.timedelta(&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;days&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #b5cea8;"&gt;7&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;queryString1&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Survey_Start&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.format(&lt;/SPAN&gt;&lt;SPAN style="color: #4ec9b0;"&gt;str&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;(timeDifference))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;query1Result&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;table.query(&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;queryString1,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;out_fields&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Project'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;message&lt;/P&gt;&lt;P&gt;'where' parameter is invalid&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 15:15:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782246#M1252</guid>
      <dc:creator>GrantHaynes</dc:creator>
      <dc:date>2019-11-11T15:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python API query string</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782247#M1253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What happens if you print out &lt;SPAN style="color: #d4d4d4;"&gt;queryString1&lt;/SPAN&gt;, maybe it doesn't fit to Survey_Start field?&lt;/P&gt;&lt;P&gt;Is this helpful?&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.jquery-az.com/python-datetime-to-string/" title="https://www.jquery-az.com/python-datetime-to-string/"&gt;4 Examples to convert Python datetime to string&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 15:35:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782247#M1253</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2019-11-11T15:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Python API query string</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782248#M1254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured it out, the query string needs the dates in a very specific format, thanks for helping out.&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #6a9955;"&gt;#&amp;nbsp;time&amp;nbsp;difference&amp;nbsp;for&amp;nbsp;querying&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;timeDifference&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;datetime.datetime.now()&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;datetime.timedelta(&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;days&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #b5cea8;"&gt;7&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #6a9955;"&gt;#&amp;nbsp;create&amp;nbsp;the&amp;nbsp;query&amp;nbsp;string&amp;nbsp;for&amp;nbsp;the&amp;nbsp;first&amp;nbsp;query&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;queryString1&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Survey_Start&amp;nbsp;&amp;gt;&amp;nbsp;date&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\'&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{}&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\'&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.format(timeDifference.strftime(&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'%Y/%m/&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;%d&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;&amp;nbsp;%H:%M:%S'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 16:47:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782248#M1254</guid>
      <dc:creator>GrantHaynes</dc:creator>
      <dc:date>2019-11-11T16:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python API query string</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782249#M1255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a useful post on the various date/time query formats for feature services:&amp;nbsp;&lt;A class="link-titled" href="https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-time-queries/" title="https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-time-queries/"&gt;Querying Feature Services: Date-Time Queries&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 23:16:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-string/m-p/782249#M1255</guid>
      <dc:creator>J_R_Matchett</dc:creator>
      <dc:date>2019-11-11T23:16:09Z</dc:date>
    </item>
  </channel>
</rss>

