HOW TO
In Map Viewer for ArcGIS Online and ArcGIS Enterprise, extracting the names of the month from a date field and populating a string field with these names enhances data analysis and visualization. This process is useful in categorizing and filtering data on a month basis, facilitating temporal analysis and trend identification.
This article provides the workflow to extract the names of the month from a date field, 'Date_joined', and populating them in a new string field, 'Ext_Month', using Arcade in Map Viewer.
Note: Skip to Step 3 if the script is being run on an existing field.
var date = $feature.<field_name>;
if (!IsEmpty(date)) {
var monthNumber = Text(Month(date) + 1, '00');
var months = {
"January": "01",
"February": "02",
"March": "03",
"April": "04",
"May": "05",
"June": "06",
"July": "07",
"August": "08",
"September": "09",
"October": "10",
"November": "11",
"December": "12"
};
for (var key in months) {
if (months[key] == monthNumber) {
return key;
}
}
return "Invalid month number";
} else {
return "Date not available";
}
Below is the full working code of the Arcade expression.
var date = $feature.Date_joined;
if (!IsEmpty(date)) {
var monthNumber = Text(Month(date) + 1, '00');
var months = {
"January": "01",
"February": "02",
"March": "03",
"April": "04",
"May": "05",
"June": "06",
"July": "07",
"August": "08",
"September": "09",
"October": "10",
"November": "11",
"December": "12"
};
for (var key in months) {
if (months[key] == monthNumber) {
return key;
}
}
return "Invalid month number";
} else {
return "Date not available";
}

The table shows the month extracted from the date field, which is then populated as text in the newly created string field.

Article ID: 000033574
Get help from ArcGIS experts
Start chatting now