How to format a esriFieldTypeDate parameter in a json url query to an ESRI REST server

1241
1
01-18-2022 06:57 AM
NazeshKaneria
New Contributor

I'm trying to query this API, filtering by the RptDt field, which is type esriFieldTypeDate.

The basic query looks like this:

https://dhsgis.wi.gov/server/rest/services/DHS_COVID19/COVID19_WI_V2/MapServer/11/query?where=1%3D1&outFields=*&outSR=4326&f=json

It's easy to filter a numeric variable like POS_CUM_SUM like so:

"https://dhsgis.wi.gov/server/rest/services/DHS_COVID19/COVID19_WI_V2/MapServer/11/query?where=%20(POS_CUM_CP%20%3D%200%20OR%20POS_CUM_CP%20%3D%2010)%20&outFields=*&outSR=4326&f=json"

I can't figure out how to format the minimum and maximum arguments for the date field RptDt.

  • because the attributes of RptDt are formatted as unix timestamps: 1642255200000, 1642428000000. But that returns error code 400.
https://dhsgis.wi.gov/server/rest/services/DHS_COVID19/COVID19_WI_V2/MapServer/11/query?where=%20(RptDt%20%3D%20'1642255200000'%20OR%20RptDt%20%3D%20'1642428000000')%20&outFields=*&outSR=4326&f=json
  • Then, I noticed that the field length for RptDt is 8, so I tried rounding the unix timestamp to 8 digits (16422552, 16424280), but that also gives error code 400.

  • I tried using YYYYMMDD format (20210101 to 20211231), this didn't give an error, but the response has no features. Most of the dates do fall this period.

https://dhsgis.wi.gov/server/rest/services/DHS_COVID19/COVID19_WI_V2/MapServer/11/query?where=%20(RptDt%20%3D%20%2720210101%27%20OR%20RptDt%20%3D%20%2720211231%27)%20&outFields=*&outSR=4326&f=json

I haven't been able to find a solution in the ArcGIS REST APIs documentation. Does anyone understand what's missing from my queries?

0 Kudos
1 Reply
JamieKelly1
Occasional Contributor

Close with the YYYYMMDD format - if you use YYY-MM-DD and enclose with single quote it should work.

There is also a Date function that is sometimes required for local ArcGIS Server services.

i.e.

where=RptDt > Date '2021-01-01' or where=RptDt > '2021-01-01' will both work for ArcGIS Online services.

0 Kudos