Arcade expression for 6 years after effective date

410
3
Jump to solution
06-29-2022 03:45 PM
Labels (1)
L77
by
Occasional 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;

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
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.

 

JohannesLindner_0-1656578743535.png

 

 

Then you can change the legend labels:

JohannesLindner_1-1656578785670.png

 

And that's it.

JohannesLindner_2-1656578852149.png

 


Have a great day!
Johannes

View solution in original post

0 Kudos
3 Replies
SteveCole
Frequent 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)

 

0 Kudos
JohannesLindner
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.

 

JohannesLindner_0-1656578743535.png

 

 

Then you can change the legend labels:

JohannesLindner_1-1656578785670.png

 

And that's it.

JohannesLindner_2-1656578852149.png

 


Have a great day!
Johannes
0 Kudos
L77
by
Occasional Contributor

Thank you so much, I really appreciate the help!

0 Kudos