AnsweredAssumed Answered

How to use values from arcpy.GetParameters in expression?

Question asked by ga_bi on Aug 15, 2015
Latest reply on Aug 15, 2015 by ga_bi

Hi, I have a big big problem

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).

I really want to make some parameters to enable users of my tool to set their own settings. This is my code:


import arcpy

from arcpy import env

env = "C:/Users/Desktop/an1"


inputfc = arcpy.GetParameterAsText(0)

outputfc = arcpy.GetParameterAsText(1)

dateFrom = arcpy.GetParameterAsText(2)

dateTo = arcpy.GetParameterAsText(3)

xyTolerance = arcpy.GetParameterAsText(4)


select = inputfc + "_sel"

where_clause = ' "DATE" > date \'dateFrom\' AND "DATE" < date \'dateTo\' '

arcpy.Select_analysis(inputfc, select, where_clause)


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!

("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: where_clause = ' "DATE" > date '2015-01-01' AND "DATE" < date '2015-02-01' ') everything works.