Filter based on current or future dates in AGOL

6871
24
05-10-2015 03:31 PM
RobbHodges
Occasional Contributor III

Is it possible to set a filter to show outages that have yet to be completed by date? We will have a start date/time and an end date/time. I would like to hide the outages that have expired. I was thinking about creating a new yes/no field that I can filter that way, but I'd like to avoid having a user to have to go back and enter that in. I'd like to just hide the results after the completion date automatically. Can this be done?

Thanks!

0 Kudos
24 Replies
RussRoberts
Esri Notable Contributor

You can set filters on your layer and use dates in these filters like: Date "is not between" Date a & Date b. Or if you had a field that has the expired domain(yes/no) you can use that which might work for your setup if the expired date could be a different value for each feature on the map.

Hope this helps.

Russ

0 Kudos
by Anonymous User
Not applicable

Is there way to set a filter; using a date query of date>=5/1/2015, during the [create replica] process within the REST services of ArcGIS Online!?

0 Kudos
RobbHodges
Occasional Contributor III

That should work, thanks! I think I was trying to over complicate it.

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

For Hosted services, if you allow non standard queries, you can use the sql server date syntax.  Here is an example that will only show feature created in the last 30 seconds.

DATEDIFF(s,DATEADD(s,30,CreationDate),GETDATE()) < 0

NilsBabel
Occasional Contributor II

Does this only work with Hosted Feature services then?  I have a feature service I have added to AGOL from a local ArcGIS Server.  The date fields don't show up when I try and create a filter. 

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

The syntax I provided above is for SQL Server and ArcGIS Online hosted data.  If you use a different database, you will need to determine the syntax for that database,  You will also need date fields so enable editor tracking is one way to get these.

0 Kudos
NilsBabel
Occasional Contributor II

Ok, thanks.  One of my feature services I am in control of and know that the database is SQL Server and the fields are date fields.  This one does show the date fields in the filter window.  However it doesn't let me add an expression in the value field.  Where would I add the expression above in a web map filter window?

Also, another feature service that I use but am not in control of has date/time fields but I'm unsure of what database format it is in.  The date/time fields do not show up in the drop down in the filter window.  Why would that be?

Thanks!

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Oh, you need to modify the json that makes up the webmap manually, the UI does not allow you to specify this query.  The AGO-Assistant can help.  Just be careful, it is easy to mess the json up.

0 Kudos
NilsBabel
Occasional Contributor II

AGO-Assistant?