Select to view content in your preferred language

# Arcade expression for 6 years after effective date

538
3
Jump to solution
06-29-2022 03:45 PM
Labels (1)
by
Frequent Contributor

I need help writing an expression to use in ArcGIS online in a hosted feature service for symbolizing forest practice application data.

This is what I need it to display:

If (The effective date plus 6 years)= date before today,  Label & Symbol: "6 year moratorium has ended"

If (The effective date plus 6 years)= date after today,  Label & Symbol: "Active Permit"

This is the dataset I am using:

https://www.arcgis.com/home/webmap/viewer.html?url=https%3A%2F%2Fgis.dnr.wa.gov%2Fsite2%2Frest%2Fser...

I started out writing this, but it isn't correct.

var startDate = \$feature["EFFECTIVE_DT"];
var sixyears = DateAdd(startDate,6, 'years')
return sixyears;

1 Solution

Accepted Solutions
MVP Frequent Contributor

You're almost there. The last step is to determine whether the date you calculated is before or after today:

``````var startDate = \$feature["EFFECTIVE_DT"];
var sixyears = DateAdd(startDate,6, 'years')
return sixyears < Today()``````

This will return true for permits that passed the moratorium date, false for active permits.

Then you can change the legend labels:

And that's it.

Have a great day!
Johannes
3 Replies
Honored Contributor

Maybe try something like this before your DateAdd line? Maybe it's not treating the date as you expect it to be..

``var recordDate = Date(\$feature.dateField)``

MVP Frequent Contributor

You're almost there. The last step is to determine whether the date you calculated is before or after today:

``````var startDate = \$feature["EFFECTIVE_DT"];
var sixyears = DateAdd(startDate,6, 'years')
return sixyears < Today()``````

This will return true for permits that passed the moratorium date, false for active permits.

Then you can change the legend labels:

And that's it.

Have a great day!
Johannes
by
Frequent Contributor

Thank you so much, I really appreciate the help!