arcpy.MakeFeatureLayer_management(points, 'points_layer', """ "Installa_1" >= '01/01/2010' """)
I'm new to Python and I have been trying to figure this out this line of code all day and its driving me crazy. I keep getting an "ERROR 000358: Invalid expression "Installa_1" >= '01/01/2010' ". The data field is in DATE format. What is the proper way to query arcmap data by date. I guess I'm missing something, regular SQL coding was never this bad. If there is some special function I can Google the details.
Thanks,
Solved! Go to Solution.
Try this format:
""" "Installa_1" >= DATE '2010-01-01' """
What type of geodatabase are you working with? The query syntax can vary between various systems. See: SQL reference for query expressions used in ArcGIS
EDIT:
I did some additional tests with a file geodatabase. It seems that how the field is quoted (single, double or none) also has an effect.
# using a file geodatabase with desktop 10.5, the following also worked
""" 'Installa_1' >= '01/01/2010' """
"'Installa_1' >= '01/01/2010'"
"Installa_1 >= DATE '01/01/2010'"
"Installa_1 >= DATE '2010/01/01'" # I generally use this format
# the following failed
""" "Installa_1" >= '01/01/2010' """
"Installa_1 >= '01/01/2010'"
Try this format:
""" "Installa_1" >= DATE '2010-01-01' """
What type of geodatabase are you working with? The query syntax can vary between various systems. See: SQL reference for query expressions used in ArcGIS
EDIT:
I did some additional tests with a file geodatabase. It seems that how the field is quoted (single, double or none) also has an effect.
# using a file geodatabase with desktop 10.5, the following also worked
""" 'Installa_1' >= '01/01/2010' """
"'Installa_1' >= '01/01/2010'"
"Installa_1 >= DATE '01/01/2010'"
"Installa_1 >= DATE '2010/01/01'" # I generally use this format
# the following failed
""" "Installa_1" >= '01/01/2010' """
"Installa_1 >= '01/01/2010'"
Thank you Randy for restoring my sanity! The first example with DATE fixed the problem. I figured it would be a simple fix. The data was from a shapefile so I guess that is why the other examples you listed did not work. Thanks also for the SQL reference link!