<?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 field calculator in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777753#M1054</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A WHERE clause of &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;"fld==qry0"&lt;/SPAN&gt; is not correct for a couple of reasons.&amp;nbsp; First, the SQL equality operator is a single equal sign, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;=&lt;/SPAN&gt;, and not a double, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;==&lt;/SPAN&gt;.&amp;nbsp; Second, the variable &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;qry0&lt;/SPAN&gt; is a Python construct, and neither SQL nor the server know anything about it so it will generate an error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Dec 2019 21:08:43 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-12-21T21:08:43Z</dc:date>
    <item>
      <title>Python API field calculator</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777751#M1052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been inclined to use the layer calculator since it is much faster than updating features using the API.&amp;nbsp; The feature update also fails if for example I try to update a large set of features at one time.&amp;nbsp; The layer calculator does the job much faster but I am having to scale the query as it limits the type of query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is what I have encountered a problem with.&amp;nbsp; I want to limit the calculation query by a date field and a time stamp or any way that makes comparing a field and a date possible.&amp;nbsp; How can I coerce the date data or the field to match a certain format?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Below is a code snippet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;val = datetime.today()&amp;nbsp; # today's date&lt;/P&gt;&lt;P&gt;fld = 'todayis'&amp;nbsp; # featrue table field containng datetime&lt;/P&gt;&lt;P&gt;valx = datetime.strftime(datetime.today(),'%Y%m%d')&lt;/P&gt;&lt;P&gt;qry0 = "format({},'yyyyMMdd') &amp;lt;&amp;gt; '{}'".format(fld,val)&lt;/P&gt;&lt;P&gt;val2 =&amp;nbsp;&lt;SPAN&gt;datetime.today() + timedelta(days=7)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fld2="nextweekdy'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;result = lyr.calculate(where=qry0,calc_expression={"field" : fld2 , "value" : val2})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running this code I get an error saying where parameter is invalid.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RuntimeError: &lt;BR /&gt;'where' parameter is invalid&lt;BR /&gt;(Error Code: 400)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any insights?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2019 00:09:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777751#M1052</guid>
      <dc:creator>MaazaMekuria</dc:creator>
      <dc:date>2019-12-17T00:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python API field calculator</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777752#M1053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think something is missing in your where query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;lyr.calculate(where="fld==qry0",calc_expression={"field" : fld2 , "value" : val2})‍‍&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>Sat, 21 Dec 2019 16:45:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777752#M1053</guid>
      <dc:creator>KarstenRank</dc:creator>
      <dc:date>2019-12-21T16:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python API field calculator</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777753#M1054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A WHERE clause of &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;"fld==qry0"&lt;/SPAN&gt; is not correct for a couple of reasons.&amp;nbsp; First, the SQL equality operator is a single equal sign, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;=&lt;/SPAN&gt;, and not a double, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;==&lt;/SPAN&gt;.&amp;nbsp; Second, the variable &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;qry0&lt;/SPAN&gt; is a Python construct, and neither SQL nor the server know anything about it so it will generate an error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Dec 2019 21:08:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777753#M1054</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-12-21T21:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python API field calculator</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777754#M1055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you haven't read &lt;A href="https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-time-queries/"&gt;https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-time-queries/&lt;/A&gt; already, it would be worth you time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Dec 2019 21:13:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-field-calculator/m-p/777754#M1055</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-12-21T21:13:20Z</dc:date>
    </item>
  </channel>
</rss>

