Select to view content in your preferred language

Querying a date field, but API does not return valid matches for exact date

1464
3
03-04-2022 11:18 AM
ewagstaff
Occasional Contributor

Hi all, using the ArcGIS REST API, I am unable to do a date query that gets results for the exact date matching a feature's attribute. For example, I have a feature with "created_date": 1646417844731 (2022-03-04 around 10am Pacific Time), but if I query with a 'where' param of

created_date = DATE '2022-03-04'

 
it returns no features. This syntax SHOULD be working, according to the ArcGIS blog: https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-ti...

Worth noting that the > and < operators are working exactly as expected -- both of these 'where' params return the feature I'm looking for:

created_date < DATE '2022-03-05'
created_date > DATE '2022-03-04'

 

Should I not be using the = operator to find today's matches? Please let me know if you can spot the error here.

 

0 Kudos
3 Replies
nutscrewbolt
Emerging Contributor

Hi @ewagstaff. Has this issue resolved? I am facing the same issue

0 Kudos
ewagstaff
Occasional Contributor

Hey! Haven't tried recently, but the solution for me was just using greater than AND less than to get a larger set of dates and then getting exactly what I needed by parsing the date attribute myself.

0 Kudos
AaronKoelker
Frequent Contributor

I'm having the same issue, using the ArcGIS API for Python and the .calculate() operation on a Feature Layer. I'm trying to recalculate records where the date field should be null/None but instead came into the service as 1969-12-31 19:00:00.000. Using > or < returns results, but using = does not. Using == doesn't work either (and throws an error)

Using the where query below works fine for me in this instance, but it would be nice to know how to query for an exact match in the future.  

featureLayer.calculate(where = "last_login < timestamp '1970-01-01 00:00:00.100'", calc_expression = {'field': 'last_login', 'value': None})

 

-Aaron
0 Kudos