HOW TO
A range of dates can be symbolized to represent areas that have and have not been surveyed or features that have been created for a particular period. Arcade functions such as DateDiff(), Date() and Now() can be used to isolate and symbolize specific ranges in an ArcGIS Online date field.
The following image shows a map of wilderness study areas in Utah, U.S. The table shows the survey dates for each area.
This article describes two methods to symbolize the areas; one according to the date range in days, and the other, the date range with fixed start and end dates.
The following options describe how to symbolize the range of dates using Arcade in ArcGIS Online Map Viewer.
Display the date range in days
//areas which are surveyed 30 days ago or less belong in the first group if (DateDiff(Now(), Date($feature.<field name>), 'days') <= 30) { return "Surveyed within the last 30 days" } //areas which are surveyed more than 30 days but less than 100 days ago belong in the second group else if (DateDiff(Now(), Date($feature.<field name>), 'days') > 30 && DateDiff(Now(), Date($feature.<field name>), 'days') < 100) { return "Surveyed between 30 to 100 days ago" } //areas which are surveyed 100 days ago or more belong in the third group else if (DateDiff(Now(), Date($feature.<field name>), 'days') >= 100) { return "Surveyed more than 100 days ago" } //areas which do not satisfy any of the given conditions belong in the fourth group else { return "None of these conditions" }
Note: Ensure the field used to calculate the date range is in the Date data type.
The image below shows the study areas symbolized according to three date ranges: areas surveyed within the last 30 days, areas surveyed between 30 to 100 days ago, and areas surveyed more than 100 days ago.
Display the date range with fixed start and end dates
var revegDate = Date($feature.<field name>) if (revegDate >= Date(yyyy,mm,dd) && revegDate <= Date(yyyy,mm,dd)) { return "mm/dd/yyyy- mm/dd/yyyy" } else if (revegDate >= Date(yyyy,mm,dd) && revegDate <= Date(yyyy,mm,dd)) { return "mm/dd/yyyy- mm/dd/yyyy" } else { return "Some other date range" }
Note: Fill in yyyy,mm,dd and mm/dd/yyyy manually. For the input to the Date() function, use numbers 0–11 for the month values instead of 1–12.
The image below shows the study areas symbolized according to two ranges of start and end dates: 01/05/2022–05/05/2022 and 01/07/2021–12/05/2021.
Note: Any web app created with a web map such as ArcGIS Dashboards, or mobile apps referencing the web map such as ArcGIS Field Maps, display the custom styling configured using Arcade expression.
Article ID: 000027651
Get help from ArcGIS experts
Download the Esri Support App