In AGOL allow queries/filters by current date

5162
11
12-02-2016 11:30 AM
TomRippetoe
Occasional Contributor

In AGOL, support queries or filters by the current date - whatever the current date is.  This functionality should be part of the filters for layers, setting symbology, and within widgets. Currently, you must select a fixed date, or require your user to enter a specific date.  Here are some specific use cases

  • I want our field crew to be able to see what cases were assigned to them (or created) today, so I would set the filter/query based on our 'dateAssigned' or 'dateCreated' fields = current date.
  • I want our data approvers to review data that was edited today. I would set a layer filter where our 'dateEdited' field = current date.
  • In many cases the field crew needs to know the age of a work item - older work requests should be processed first - where the "age" of a work item is based on (current date - the 'dateCreated') 
11 Comments
TomRippetoe

An additional use case is to allow the 'current date' to be set as a default value for a field when a record is created.  Similar functionality is already in place when the 'edit tracker' is enabled, i.e. CreationDate is set to the current date/time when the record is created.  I'd like the same functionality for other fields in the feature class.   Specifically, we have a 'status' field and a 'date status changed' field.  When a new record is created, I can set the default status, but I can't set the 'date status changed' field. I would to set that value to the 'current date' when the record is created.

KellyGerrow

Hi Tom,

How do your users view the data in a current date? There is functionality through date filters and the time aware app to show updating current data. Would any of these approaches work for you or is more functionality required once the date filter is applied?

Date Filters: look at the in the last option:Apply filters—ArcGIS Online Help | ArcGIS 

Time Aware app, check out the Live data options

TomRippetoe

Hi Kelly.

Thank you for replying. the challenges around 'current date' and AGOL have been a thorn in my side for while.

A filter may/could work, but its less than ideal.  Our site admin wants to see the records created "today"; To do that, they would apply the filter, select the date for 'today' from the calendar picker, and apply.  the same is true for the query widget - a user has to select a date from the calendar.  I'd like to default to the 'current date' so all the user has to do is apply the filter/query to get records created 'today' (instead of having to pick the date first). It seems like no big deal to do one extra click to select 'today', but we have multiple 'tasks' that depend on the date. over the course of a work day and then a work week, and so on, the frustration of that one extra click builds.

Another example is that we would like to set a layer's symbology based on a Date calculation: the current date - the received date (the 'received date' is when the work was requested).  So, each day the symbology for a given record would change as the record 'ages'.  To work around this we have added an 'age' field to the feature class, and execute a python script nightly to calc the value for the age field.  To me the more straight forward approach would be to have a 'native' current date function we could use.

I should mention that the new Arcade scripting language offers this functionality. I have been able to use it in a test map:

var startDate = Date($feature.DateReceived);
var age = DateDiff(Date(), startDate, 'days');
return Round(age, 0);

However, it seems that Collector does not support Arcade expressions so no data appears when viewing the map in Collector. So we are back to the old 'nightly processing' routine.

Thanks again for your interest. I am happy to provide more details, talk about use cases, etc. let me know if I can help out.

tom

NicoleGamble1

Hi Tom,

I came across your idea while researching this functionality and wanted to mention that you can use filters to view features created today by using the "in the last" operator mentioned in the Apply filters documentation.

I think this should have the dynamic aspect you were looking for I'm not sure if that option existed or not when you originally made this post in December so I thought I'd mention it just in case. 

DamonEisenach

I have a Closure map with a start date/time and end date/time

I want to only show things between the two date/time fields

Current date between field A and field B

I have planned events I only want to show the next week or months schedule.

is on/before NOW/Today +/- # minutes/hours/days/weeks/months/years
is on/after NOW/Today +/- # minutes/hours/days/weeks/months/years

in the Next # minutes/hours/days/weeks/months/years
not in the Next # minutes/hours/days/weeks/months/years

is between NOW/Today +/- # minutes/hours/days/weeks/months/years and NOW/Today +/- # minutes/hours/days/weeks/months/years
is not between NOW/Today +/- # minutes/hours/days/weeks/months/years and NOW/Today +/- # minutes/hours/days/weeks/months/years

KevinMayall

+1.   I have the exact same situation.

JamieLambert

We have the same issue - trying to only show records on a map (for field survey status) that were created 'today' - i.e. today's date not an hour filter. 'Today' is a very different filter to the last 24 hours! If we have a record captured at 8pm on the 21st, and field crews are reviewing the status map at 7am on the 22nd, a record from yesterday will show up. If i set the time filter to 12 hours and a record is captured at 6am, by 6pm it is no longer on the map!

Having 'today' (date) option would be very useful. Creation Date = Today

Previously when i have checked our data, the above filter really says in the last 24 hours not in the last calendar day.

NaomiBegg2

This is what I am looking at doing.

MarvinDavis

I'm wanting to filter features whose date is in the past (i.e. after Now() or Today()). Instead, I have found success by saying "not in the last 100 years" so nothing in the near past ever shows. Not a perfect workaround for a couple generations from now.

BronwenHughes

I would like to display all features with an expiry date three months in the future, i.e. three months ahead of "today".