<?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 error select analysis invalid expression for a number variable in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679130#M52630</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If it is just a numerical field, you should be able to do it similar to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query = " \"daily_YearMonthDay\" = 20131105 "
arcpy.Select_analysis(daily_stations, daily_stations_Select, query)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...or, in keeping your variable ref 'x':&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
x=20131105
query = " \"daily_YearMonthDay\" = {0} ".format(x)
arcpy.Select_analysis(daily_stations, daily_stations_Select, query)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is native Python, see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/2/library/string.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://docs.python.org/2/library/string.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:36:54 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2021-12-12T04:36:54Z</dc:date>
    <item>
      <title>python error select analysis invalid expression for a number variable</title>
      <link>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679129#M52629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi I'm trying to do a select analysis with a number variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
x=20131105
arcpy.Select_analysis(daily_stations, daily_stations_Select, "\"daily_YearMonthDay\" = x")
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried a number of different ways but keep getting errors. I obtained this code by building the select in modelbuilder and exporting to python. I replaced the number (20131105) that I used in modelbuilder with the variable x.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000358: Invalid expression daily_YearMonthDay&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2013 20:18:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679129#M52629</guid>
      <dc:creator>AndrewL</dc:creator>
      <dc:date>2013-11-11T20:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: python error select analysis invalid expression for a number variable</title>
      <link>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679130#M52630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If it is just a numerical field, you should be able to do it similar to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query = " \"daily_YearMonthDay\" = 20131105 "
arcpy.Select_analysis(daily_stations, daily_stations_Select, query)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...or, in keeping your variable ref 'x':&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
x=20131105
query = " \"daily_YearMonthDay\" = {0} ".format(x)
arcpy.Select_analysis(daily_stations, daily_stations_Select, query)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is native Python, see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/2/library/string.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://docs.python.org/2/library/string.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:36:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679130#M52630</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T04:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: python error select analysis invalid expression for a number variable</title>
      <link>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679131#M52631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you! It worked. I kept the variable x.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 12:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679131#M52631</guid>
      <dc:creator>AndrewL</dc:creator>
      <dc:date>2013-11-12T12:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: python error select analysis invalid expression for a number variable</title>
      <link>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679132#M52632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thank you! It worked. I kept the variable x.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That's great....don't forget to mark the question answered so I'll win a lifetime pass to the ESRI user conferences (okay, that latter part was pure fantasy, but you should get into the habit of properly marking answers so that this thread is considered 'closed'.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Glad to assist!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 13:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-select-analysis-invalid-expression/m-p/679132#M52632</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-11-12T13:10:22Z</dc:date>
    </item>
  </channel>
</rss>

