Select to view content in your preferred language

Arcade Style Expression to filter by date

599
1
Jump to solution
10-18-2023 03:56 AM
NygrenOhto
Occasional Contributor

I'm trying to filter out events in my Feature Layer by dates. I am doing this in the ArcGIS Online Map Viewer Style expressions. It works otherwise fine, but this script won't show events that are happening today as Active:

 

 

var start = $feature.start;
var end = $feature.end;
var today = Now();

var event = When(
  end >= today && start <= today, 'Active', 'Upcoming'
);

return event;

 

 

 
The dates are in Esri Datetime format:
start = 10/18/2023 3:00 am.
end = 10/18/2023 3:00 am.
 
It also doesn't show event that start today and end another day:
start = 10/18/2023 3:00 am.
end = 10/19/2023 3:00 am.
0 Kudos
1 Solution

Accepted Solutions
NygrenOhto
Occasional Contributor

I managed to fix this myself by changing the start to this:

var alku = Date(Year($feature.alkaa), Month($feature.alkaa), Day($feature.alkaa), 0, 0, 0, 0);


The problem was that AGOL changed the time to datetime and added the default time to the date.

View solution in original post

0 Kudos
1 Reply
NygrenOhto
Occasional Contributor

I managed to fix this myself by changing the start to this:

var alku = Date(Year($feature.alkaa), Month($feature.alkaa), Day($feature.alkaa), 0, 0, 0, 0);


The problem was that AGOL changed the time to datetime and added the default time to the date.

0 Kudos