I have web service that is showing road closures that usually last less than a day. I am trying to find a way to only show the closures on the map that are active, so after the start date/time and before the end date/time. I have been trying to accomplish this by using an arcade symbology expression, but I can't figure out. Says the expression is right but doesn't show the closures I want on the map.
Is this the best way to accomplish this? Does anybody have an idea on how to best set up the expression? I have 3 types of date time fields to choose from, I can't figure out any of them out. I have attached an image of the field options I have.
Here is one expression I tried with the epoch date fields.
//ToLocal(Timestamp())
You can't directly compare the epoch number to a Date like that. You'll have to convert it to a Date. Arcade can create a Date from an epoch number, it must be in milliseconds (adding "000" to your attributes). For example:
If you want to use that field, then your expression should look like this
var started = Date($feature.closureStartEpoch + '000');
var closed = Date($feature.closureEndEpoch + '000');
var present = Date()
If (present >= started && present <= closed) return "Open"
return "Closed"
Thanks for this. This helps. It kind of led me to a knew issue though. I don't want the Closed events to show on the map. I can change the symbol to be blank, but when I click on a feature that is Open, it could have 4 other features under it that are closed and show up in the popup. So is there anyway to just show the date for the Open events on the map and in the popup?
I wish they we could just run arcade expressions in the filter tool.