Arcade expression to format date

10738
5
Jump to solution
06-25-2023 06:33 PM
FrankHerbert
Occasional Contributor

I have created an Arcade expression to group attributes and return them in a list. I'm very new to Arcade and having trouble understanding how to format the date. I have attached an image of the expression showing my progress.

Currently the date is returned as "Jun 23, 2023, 10:31:00 AM GMT+12" but I would like to see it as 23/06/23.

Please can someone tell what I need to fix to change this?

Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor
0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

this may be useful

Date functions | ArcGIS Arcade | ArcGIS Developers


... sort of retired...
0 Kudos
SSchott_CLAU
Occasional Contributor

@FrankHerbert , you can use the date functions as mentioned above.

Below is the code which I use in my maps to format the dates.

Day($feature.date) + "/" + ISOMonth($feature.date) + "/" + ISOYear($feature.date)

SSchott_CLAU_0-1687754512199.png

 

KenBuja
MVP Esteemed Contributor

The Text function is very handy to make various date strings

Text(Now(), 'YY/MM/DD');

 

MHergel
Occasional Contributor

Hi,

To get the date to be returned in a YYYY/MM/DD format you could try

var dateWithoutTime = Left(group.Date, 10);

group.Date is where you would put the field or variable that the date information is stored in. Below is an example of how I used this in my arcade code in AGOL Map Viewer to print out dates from a group in a chronological list.

 

for (var group in ordered){
// Extract date part from group.Date
var dateWithoutTime = Left(group.Date, 10); // Assuming group.Date is in 'YYYY-MM-DD' format
list += dateWithoutTime + TextFormatting.NewLine;
}

list

 

I hope this helps 😊

tikola
by Esri Contributor
Esri Contributor

I have a this kind of variant of this same issue.

a5c49f44-7b7e-43b0-9038-9c49c8c0b34a.jpg

We manage pipe networks. Pipes have install date - or actually typically there is stored Year and Month and never the actual Day. When we store that to ArcGIS Online Water Distribution network we calculate install date. Depending how that calculation goes there is a risk that we get some time for that event too. I can easily delete time by setting each date in midnight with function 

Date(Year($feature.installdate),Month($feature.installdate),Day($feature.installdate),0,0,0,0,0)

The problem is that this Arcade function in ArcGIS Pro against ArcGIS Online is fairly slow and I would like to choose only features that are not in midnight. So how to choose features that has in time certain time to focus calculation only in neccessary features. I have thousands of features and maybe hundreds of them have this issue.

Actual time of the day is not really needed in this kind of pipe installations at all - year and month (and maybe day) is definetly accurately enough. 

This one chooses the data for one day but I am looking any date where time is for example that 11pm

installdate = timestamp '2011-07-01 23:00:00.000'

 

0 Kudos