HOW TO

Symbolize a range of dates using Arcade in ArcGIS Online Map Viewer

Last Published: May 18, 2022

Summary

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.

Map of the wilderness study areas.

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.

Procedure

The following options describe how to symbolize the range of dates using Arcade in ArcGIS Online Map Viewer.

Display the date range in days

  1. In ArcGIS Online, navigate to the hosted feature layer on the My Content tab, and click Open in Map Viewer.
  2. In the Layers pane, click the layer to select it.
  3. On the Settings (light) toolbar, click Styles The Styles icon. In the Styles pane, click Expression. A new expression page is opened.
  4. In the Expression box, use the following expression:
//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.
  1. Click OK to apply the expression. The symbology is updated.
  2. Optionally, click Style options under Types (unique symbols) to customize the display of the layer. In the Styles pane, click Done.

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.

The study areas symbolized in three different date ranges.

Display the date range with fixed start and end dates

  1. Repeat Steps 1 through 3 from the method above. In the Expression box, use the following expression:
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.

The study areas symbolized with fixed start and end dates.
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

Software:
  • ArcGIS Online

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic