<?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: How to use values from arcpy.GetParameters in expression? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270819#M20911</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need a date field...do you have a Date field? and do the dates conform to what you say works?&amp;nbsp; You can create a derived parameter if you had a field parameter, set to default, then the values derived from it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/setting-script-tool-parameters.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/setting-script-tool-parameters.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/select.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/select.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;SQL syntax is covered here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 15 Aug 2015 16:32:53 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2015-08-15T16:32:53Z</dc:date>
    <item>
      <title>How to use values from arcpy.GetParameters in expression?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270818#M20910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have a big big problem &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;I am writing a script in PythonWin and want to use it as a Script in ArcGIS toolbox (I have created a script in ArcMap and it is linked with pythonWin script). &lt;/P&gt;&lt;P&gt;I really want to make some parameters to enable users of my tool to set their own settings. This is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;env = "C:/Users/Desktop/an1"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inputfc = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;outputfc = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dateFrom = arcpy.GetParameterAsText(2)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dateTo = arcpy.GetParameterAsText(3)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;xyTolerance = arcpy.GetParameterAsText(4)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select = inputfc + "_sel"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where_clause = ' "DATE" &amp;gt; date \'dateFrom\' AND "DATE" &amp;lt; date \'dateTo\' '&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;arcpy.Select_analysis(inputfc, select, where_clause)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you see, I want to get the date from the value of parameter. Unfortunately, I cannot find a way to use it in my where_clause expression! &lt;/P&gt;&lt;P&gt;("DATE" is a field name). How can I access to these values? The problem is, as I suppose, in the expression itself. When I paste a normal date there (like: &lt;STRONG&gt;where_clause = ' "DATE" &amp;gt; date '2015-01-01' AND "DATE" &amp;lt; date '2015-02-01' '&lt;/STRONG&gt;​) everything works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Aug 2015 16:08:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270818#M20910</guid>
      <dc:creator>GabrielaMandziuk</dc:creator>
      <dc:date>2015-08-15T16:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use values from arcpy.GetParameters in expression?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270819#M20911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need a date field...do you have a Date field? and do the dates conform to what you say works?&amp;nbsp; You can create a derived parameter if you had a field parameter, set to default, then the values derived from it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/setting-script-tool-parameters.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/analyze/creating-tools/setting-script-tool-parameters.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/select.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/tools/analysis-toolbox/select.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;SQL syntax is covered here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://desktop.arcgis.com/en/desktop/latest/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Aug 2015 16:32:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270819#M20911</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-08-15T16:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use values from arcpy.GetParameters in expression?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270820#M20912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My parameter has a data type "Date" and I do have a DATE field in my feature class attribute table. I will study your materials, thanks for the answear &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Aug 2015 16:51:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270820#M20912</guid>
      <dc:creator>GabrielaMandziuk</dc:creator>
      <dc:date>2015-08-15T16:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use values from arcpy.GetParameters in expression?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270821#M20913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. I have finally solved my problem!!!&lt;/P&gt;&lt;P&gt;As I thought, the problem was in the expression. Now the code is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;env = "C:/Users/Desktop/an1"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inputfc = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;outputfc = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;dateFrom = arcpy.GetParameter(2)&lt;/P&gt;&lt;P&gt;dateTo = arcpy.GetParameter(3)&lt;/P&gt;&lt;P&gt;xyTolerance = arcpy.GetParameterAsText(4)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select = inputfc + "_sel"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where_clause = '"DATE" &amp;gt; date \'%s\' AND "DATE" &amp;lt; date \'%s\' ' % (dateFrom, dateTo)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.Select_analysis(inputfc, select, where_clause)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;integrated = select + "_int"&lt;/P&gt;&lt;P&gt;arcpy.CopyFeatures_management(inputfc, integrated)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.Integrate_management(integrated, str(xyTolerance) + " Meters")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ce = arcpy.CollectEvents_stats(integrated, outputfc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it'' help someone in the future &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Aug 2015 18:56:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-values-from-arcpy-getparameters-in/m-p/270821#M20913</guid>
      <dc:creator>GabrielaMandziuk</dc:creator>
      <dc:date>2015-08-15T18:56:17Z</dc:date>
    </item>
  </channel>
</rss>

