<?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 Problem with GetParameter when making an expression in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-getparameter-when-making-an/m-p/1237063#M62903</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I tried to make a selection according to an input date given by a user from my toolbox. However, when I use the arcpy.GetParameter, it keeps returning error 000385. If I use a specific date in the query expression, I can get a result.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;date_input = arcpy.GetParameter(0)&lt;/P&gt;&lt;P&gt;date_select = "USER_Date_fin = timestamp 'date_input'"&lt;BR /&gt;arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION", date_select )-------------------doesn't work&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;date_input = arcpy.GetParameter(0)&lt;/P&gt;&lt;P&gt;date_select = "USER_Date_fin = timestamp '2022-11-30 00:00:00'"&lt;BR /&gt;arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION", date_select )---------------------work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2022 22:52:56 GMT</pubDate>
    <dc:creator>Xitermelon</dc:creator>
    <dc:date>2022-12-01T22:52:56Z</dc:date>
    <item>
      <title>Problem with GetParameter when making an expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-getparameter-when-making-an/m-p/1237063#M62903</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I tried to make a selection according to an input date given by a user from my toolbox. However, when I use the arcpy.GetParameter, it keeps returning error 000385. If I use a specific date in the query expression, I can get a result.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;date_input = arcpy.GetParameter(0)&lt;/P&gt;&lt;P&gt;date_select = "USER_Date_fin = timestamp 'date_input'"&lt;BR /&gt;arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION", date_select )-------------------doesn't work&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;date_input = arcpy.GetParameter(0)&lt;/P&gt;&lt;P&gt;date_select = "USER_Date_fin = timestamp '2022-11-30 00:00:00'"&lt;BR /&gt;arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION", date_select )---------------------work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 22:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/problem-with-getparameter-when-making-an/m-p/1237063#M62903</guid>
      <dc:creator>Xitermelon</dc:creator>
      <dc:date>2022-12-01T22:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with GetParameter when making an expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-getparameter-when-making-an/m-p/1241780#M63509</link>
      <description>&lt;P&gt;You are trying to pass a variable as a string - this won't work. Presumably the variable data_input stores datetime object. The Python interpreter will literally see this:&amp;nbsp;&lt;SPAN&gt;"USER_Date_fin = timestamp 'date_input'". It will not see see the string as a variable and automatically read it's contents.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;What you need to do is insert the actual value the date_input variable holds into the string. You can do this with &lt;A href="https://realpython.com/python-string-formatting/#3-string-interpolation-f-strings-python-36" target="_self"&gt;string formatting&lt;/A&gt;. Try this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;f"USER_Date_fin = {date_input}"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Note, depending on the format of the datetime you're passing and what the query requires, you might need to work this over a little more. I didn't test this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 22:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/problem-with-getparameter-when-making-an/m-p/1241780#M63509</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2022-12-15T22:37:57Z</dc:date>
    </item>
  </channel>
</rss>

