Trying to query relative dates in AGOL web map

1177
3
Jump to solution
01-28-2020 12:03 PM
KateNewell1
Occasional Contributor II

I'm creating a map in which I only want to show permits that have been finaled in the last year (or 6 months, etc.)  AGOL does not seem to allow the "Is within..." query.  This is weird because you can use the "Is within" in Dashboard.  Does anyone know how to query a date field in a web map using something other than a hard date? I need to query relative dates.  

0 Kudos
1 Solution

Accepted Solutions
SteveCole
Frequent Contributor

Kate,

I had to tackle this with a recent webmap where I wanted to show only features that were projected to be replaced within 12 years. I was hoping to use a query filter on an Arcade field but that's not supported. What was suggested (and works) is to use the AGO Assistant tool to modify the underlying definition query used on the layer in your webmap. In my case, my layer's definition query was modified to this:

(a5facilitycat = 'Curb Ramp') AND (m9upgradeyr >= EXTRACT(YEAR FROM CURRENT_DATE()) ) AND (m9upgradeyr <= EXTRACT(YEAR FROM CURRENT_DATE()) + 12 )

My attribute field "m9upgradeyr" was field with the 4 digit year.

Hope this helps. Good luck!

Steve

View solution in original post

3 Replies
SteveCole
Frequent Contributor

Kate,

I had to tackle this with a recent webmap where I wanted to show only features that were projected to be replaced within 12 years. I was hoping to use a query filter on an Arcade field but that's not supported. What was suggested (and works) is to use the AGO Assistant tool to modify the underlying definition query used on the layer in your webmap. In my case, my layer's definition query was modified to this:

(a5facilitycat = 'Curb Ramp') AND (m9upgradeyr >= EXTRACT(YEAR FROM CURRENT_DATE()) ) AND (m9upgradeyr <= EXTRACT(YEAR FROM CURRENT_DATE()) + 12 )

My attribute field "m9upgradeyr" was field with the 4 digit year.

Hope this helps. Good luck!

Steve

KateNewell1
Occasional Contributor II

Yes! Thank you so much Steve! That worked perfectly.  Was this a suggested solution from ESRI? Anything to look out for when AGOL gets updates and such? Really grateful for your response. Thank you!!!!

SteveCole
Frequent Contributor

No problem, glad it work out for you. I came across this solution by searching Geonet so I can't say for certain that the advice came from a bona fide ESRi employee or just a fellow user. AGO Assistant is (wink wink nudge nudge) not officially supported so always make a back up of whatever you're about to edit.

The SQL parameters you used are somewhat illustrated in the AGOL documentation. Here is the link to the relevant location.

Steve

0 Kudos