How do you select a specific date with Arcade?

648
4
Jump to solution
06-21-2022 12:03 PM
AdamGebhart
Occasional Contributor III

@XanderBakker 

Xander:

You've been my go-to person for all things Arcade.  Is there any chance you can help me here?

I have a field (StatusDate, type = date) that needs to be displayed in a popup.  When that date is 12/31/22 I want to ignore the value and leave it blank.  All other values will be shown.

I have tried these expressions and they do NOT ignore the 12/31/22 values.

1) IIF(Find(12/31/22,$feature.StatusDate) > -1, "", $feature.StatusDate)

2) IIF(Find('12/31/22',$feature.StatusDate) > -1, "", $feature.StatusDate)

3) IIF($feature.StatusDate == 12/31/22,"", $feature.StatusDate)

4) IIF($feature.StatusDate == '12/31/22',"", "$feature.StatusDate")

In the feature class I only see the date value in the format above.  When I open the attributes via AGO I see "12/31/22, 6:00 PM". 

Can you, or anyone else for that matter, help?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

This is one calculation that works:

 

IIF($feature.LASTUPDATE > Date(2022,11,31) && $feature.LASTUPDATE < Date(2023,0,1), " ", $feature.LASTUPDATE);  //month is zero-based

 

View solution in original post

4 Replies
KenBuja
MVP Esteemed Contributor

This is one calculation that works:

 

IIF($feature.LASTUPDATE > Date(2022,11,31) && $feature.LASTUPDATE < Date(2023,0,1), " ", $feature.LASTUPDATE);  //month is zero-based

 

AdamGebhart
Occasional Contributor III

@KenBuja 

That worked.  Thank you very much.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @AdamGebhart , I am glad that @KenBuja shared a good solution.

Apart from the solution provided by Ken, there are many ways to do this. 

You can compare by exact date and time (probably the date has a time like 6 pm since it is stored as UTC date time and there is a difference between your local time zone and UTC):

if ($feature.StatusDate == Date(2022, 11, 31, 18, 0, 0)) { ... }

 

Another way (when the time does not matter) is to translate it to text and compare it as a string:

if (Text($feature.StatusDate, "M/D/YY") == "12/31/22") { ... }

 

AdamGebhart
Occasional Contributor III

Those worked too.  Thank you.

0 Kudos