3

I'm trying to understand how dates are queried in the ArcGIS Server REST API (v10) using the query functionality (...MapServer/find?searchText=...). If I search on a string attribute I can get a result and its date field shows the value "6/1/1995". However if I then search by the date field using "6/1/1995" I get 0 results.

Am I supposed to provide my date in a particular format? I tried reversing the date's components' ordering, changing the separator, with/without leading zeros, and even tried the timestamp to no avail. I'm not in control of the service or the data so I don't know if any settings are in place in the source data that make this more difficult. The field's format is reported as esriFieldTypeDate with length 36.

Understanding Date Time Format output in ArcGIS REST API? suggests I should be seeing the date field reported as a timestamp in the JSON output of my query but in both HTML and JSON it is "6/1/1995".

I saw this thread on the ArcGIS forum but as using a timestamp didn't help me I assume it's not relevant.

4

In 10.0 (and I believe 10.1 also), you can query dates using the syntax of the underlying database -- for example, in Oracle you can use "TO_DATE('yyyy-mm-dd hh:mm:ss','YYYY-MM-DD HH24:MI:SS')"

See documentation here: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/SQL_reference_for_query_expressions_used_in_ArcGIS/00s500000033000000/

This has changed in 10.2 where ArcGIS Server is set to use standardized queries by default, so you will need to use the format "date 'yyyy-mm-dd'": http://resources.arcgis.com/en/help/main/10.2/index.html#//015400000686000000

  • 2
    OK thanks for the info. I'm glad things have changed for 10.2 as expecting a service client to know the underlying architecture is ridiculous (and very 'ESRI') – tomfumb Mar 11 '14 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.