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))
Returns this...
"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??
Thank you!
arcgis online arcade
arcade attribute expressions
Solved! Go to Solution.
Have you tried using the Text function to format the date?
Text($feature.PrevInspDt, 'MMMM D, Y')
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[1] + " " + arr[2] +", " + arr[3];
It will return "Mar 21, 2019".
Xander,
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 again!
Todd
Have you tried using the Text function to format the date?
Text($feature.PrevInspDt, 'MMMM D, Y')
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:
Don't forget to click Mark Correct on the reply that best answered your question.
Thanks Ken, that is exactly what I needed!
Thank you! Sometimes the answer is not a long read through Arcade date documentation.