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.
Solved! Go to Solution.
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
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
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!!!!
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