I am trying to use the Arcade "date" function in an expression for a popup to return the day, month, year but without the time. Well actually would like to lose the day of the week too. The documentation I refer to the time as an "optional" field:
IIf(IsEmpty($feature.InspDt), Date($feature.PrevInspDt), Date($feature.InspDt))
"Thu Mar 21 2019 20:00:00 GMT-0400 (Eastern Daylight Time)"
So our archived time data is all mucked up and for our purposes we only really need month, day, year anyway. Is there something I can add to this Arcade Date function so that it returns the date but without the "20:00:00 GMT-0400 (Eastern Daylight Time)", and ideally without the day of the week "Thu" portion as well??
arcgis online arcade
arcade attribute expressions
Solved! Go to Solution.
Hi Todd Helt ,
You could use something like this (assuming that the input date is a string and you want to return a string):
var InspDt = "Thu Mar 21 2019 20:00:00 GMT-0400 (Eastern Daylight Time)";
var arr = Split(InspDt, ' ', 4, 0);
return arr + " " + arr +", " + arr;
It will return "Mar 21, 2019".
Thanks for your response, starting to see the light lol. I should have clarified the input date is actually not a string, but rather a date type, and I want to return a string like your snippet. Is there a slight modification you can recommend or it a whole other approach?
Thanks Ken, I had not thought of that...but just tried that and worked in my IIf function, and it worked as desired so good to go!
// Write a script to return a string of the day, month, year from a date field, to show in the pop-up.
// If the InpsDt is null, then display PrevInspDt, otherwise display InspDt
IIf(IsEmpty($feature.InspDt), Text($feature.PrevInspDt, 'MMM D, Y'), Text($feature.InspDt, 'MMM D, Y'))
I think I am getting a little confused about Arcade for labeling and Arcade for expressions in pop-ups.
Would it be correct to say that certain Arcade functions work for popups but don't work in labeling, and vice versa?
Hi Todd Helt ,
There are different profiles that define what is possible in Arcade (symbology, labels, pop-up, field calculations, different types of attribute rules and so on). If you go to the playground you can select a profile (where you want to use Arcade) and see what is possible: ArcGIS Arcade | ArcGIS for Developers
These are the different profiles you will see: