Arcade Text() Format String

8198
6
02-28-2018 11:09 AM
danbecker
Occasional Contributor III

ArcGIS Pro 2.1, attribute rule, calculation contains this expression:

Text(Now(), 'ddd D MMM Y')

This gets inserted into the features attribute table, text field:

Wed 28 Feb Y

I also tried this expression:

Text(Now(), 'ddd D MMM yyyy')

This was the result:

Wed 28 Feb yyyy

Here's the workaround (messy):

var fir = Text(Now(), 'ddd D MMM');
var sec = Text(Year(Now()));
var arr = [fir,sec];
return Concatenate(arr,' ')

6 Replies
KenBuja
MVP Esteemed Contributor

Yes, that doesn't appear to work correctly in Pro. If you use the expression "Text(Now(), 'ddd D MMM Y')" in the Playground, it returns the expected response. Using "Text(Now(), 'ddd D MMM YY')" in Pro returns Wed 28 Feb 18

XanderBakker
Esri Esteemed Contributor

It also doesn't seem to be an issue in ArcGIS Online:

by Anonymous User
Not applicable

Hey Dan,

Thanks for your post and the details. I tested the attribute rule expression in Pro 2.1.2 and it still seems to be an issue.

Text(Now(), 'ddd D MMM Y') ---> returned Thu 1 Mar Y

I am going to test a few more things and possibly write up a bug. I'll keep you posted. 

Supriya

by Anonymous User
Not applicable

I tried the expression: Text(Now(), 'ddd D MMM YYYY') and returned the proper output: Thu 1 Mar 2018 and as Ken mentioned above Text(Now(), 'ddd D MMM YY') returns another proper result: Thu 1 Mar 18

However, since there is a difference between what Pro and Playground is returning for your original expression I have written the following bug: 

BUG-000112055 - The Arcade function Now doesn't return the proper year when used as an attribute rule in ArcGIS Pro 2.1.2

Especially since this document states that a single Y is enough to reformat the date type:

Text Functions | ArcGIS for Developers 

0 Kudos
KenBuja
MVP Esteemed Contributor

You should append that bug. It fails with any date, not just Now. For example, this expression

Text($feature.Date,  'ddd D MMM Y')

yields

Fri 16 Feb Y

KoryKramer
Esri Community Moderator

It looks like the bug's synopsis was updated.  

BUG-000112055 - The Arcade expression to format date in attribute rules doesn't return the correct year results

Thanks for the details kenbuja‌ and thanks for the update Supriya_Khadke-esristaff‌!