Select to view content in your preferred language

ArcGIS Online Arcade time based expression

1369
4
Jump to solution
06-14-2021 10:46 AM
OliverSandoval
Emerging Contributor

Hello, I am new to arcade and am looking for any advice in the direction I should go for creating a script for an feature service in a web map. I want to be able to change the symbology of the layer based upon what week it is. So the script would ideally switch from Week A to Week B every 7 days and the current week's polygon borders would be highlighted in red. Any advice would be greatly appreciated!

1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

I'd possibly use the ISOWeek() Aracade method to check the numerical ISO 8601 week (week starts on Monday) of your date field value, and compare it against Now().  And have this as a symbology expression.  Something like:

//does not account for dates in the future
if ( ISOWeek($feature.yourDateField) == ISOWeek(Now()) ) {
  return 'ThisWeek'
else {
  return 'NotThisWeek'
}

 

View solution in original post

4 Replies
DavidPike
MVP Frequent Contributor

I'd possibly use the ISOWeek() Aracade method to check the numerical ISO 8601 week (week starts on Monday) of your date field value, and compare it against Now().  And have this as a symbology expression.  Something like:

//does not account for dates in the future
if ( ISOWeek($feature.yourDateField) == ISOWeek(Now()) ) {
  return 'ThisWeek'
else {
  return 'NotThisWeek'
}

 

GIS_Fox
Frequent Contributor

Hi @OliverSandoval ,

I've used a script almost identical to @DavidPike 's in his screenshot above. I used the documentation found here for reference if it helps, too: https://developers.arcgis.com/arcade/function-reference/date_functions/ 

Cheers 🙂 

Jansen Lyons - Records and GIS Section - Public Works - City of Rio Rancho, NM
OliverSandoval
Emerging Contributor

Hi @GIS_Fox thank you very much! Ill most definitely be using that! 😊!

OliverSandoval
Emerging Contributor

Awesome thank you so much David for your response! Ill try it out! 

0 Kudos