0

I have the following code below. I'm trying to search for a text inside a string from a date field and populate it with the associated month with ArcGIS Arcade. So far I just keep getting the default return statement of 'none'. Any thoughts? Does it have something to do with the Find function?

var date  = Text($feature.DATE);
if (Find('2023/01/01', date, 0) > -1) {
   return 'January';
} else {
   return 'none';
}

3 Answers 3

2

The string returned from the Text function is in the format "2023-10-16T10:02:49.456-04:00"

You have to change your if statement to this. Note that you shouldn't use reserved words (such as Date) for variable names.

var theDate  = Text($feature.DATE);
if (Find('2023-01-01', theDate, 0) > -1) {
  return 'January';
} else {
  return 'none';
}
0

this worked.

 var theDate  = Text(ToUTC($feature.DATE), 'M/D/Y');
    Var left = Left(theDate, 2);
    if (left == '1/') {
       return 'January';
    } else if (left == '2/') {
       return 'February';
    } else if (left == '3/') {
       return 'March';
    } else if (left == '4/') {
       return 'April';
    } else if (left == '5/') {
       return 'May';
    } else if (left == '6/') {
       return 'June';
    } else if (left == '7/') {
       return 'July';
    } else if (left == '8/') {
       return 'August';
    } else  (left == '9/') {
       return 'September';
    }
1
  • You can simply use Text(ToUTC($feature.DATE), 'MMMM') to return the month
    – kenbuja
    Commented Oct 19, 2023 at 12:05
0

As highlighted by Kenbuja, minus the timezone transformation.

Text($feature.DATE, 'MMMM')

See https://developers.arcgis.com/arcade/function-reference/text_functions/#text for other format string options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.