Hello,
Is it possible to create an expression for a date field so that only the date is shown rather than date and time?
I am using a date field to populate a text box, at the moment pulling in an attribute {date} and it formats as 21/11/2025, 00:00 - I just want to show the date 21/11/2025. I know that you can use an Expression instead, but I'm not sure if it's possible to format the date field in that Expression, or how to do it.
Thanks!
Are you using the newer date only field type? The widget you use for display can also affect formatting.
Anyway, to format using Arcade, use the Text function:
Text($feature.your_date_field, "dd/MM/yyyy")
I've tried adding that function into the expression box but it doesn't accept it. Is this the correct place to put it?
Thanks!
Maybe this is a difference in versions of ExB. Sorry, I should have said that I'm using the Enterprise 11.5 version, not the latest.
@StephenKing3, if you don't need the time somewhere else and the layer is housed in a web map, you can just change the "show time" setting for that field in Map Viewer:
I actually can't get the time to display at all though (in 11.5), so I'm curious what the difference is between our setups. Text widget vs the table widget:
The time does however seem to display automatically in ArcGIS Online:
If you do have access to AGOL, you can format with Arcade by clicking the "</>" icon (next to the "dynamic content" cylinder). The exact code would depend on whether you're selecting something and then showing the date, etc. but it's there that you could use the Text function. The functions offered in the expression window are pretty limited (things like minimum, maximum, etc.).
My setup is pulling in data from a feature layer generated from a Survey123 survey form. I'm not trying to display any features in the map from this, just pulling in tabular data. Thanks for the pointer to the 'show time' setting for the feature layer. You can change this for the layer visualisation and save it, but it doesn't appear to make any difference in pulling in the data field in ExB.
Ah man, that's frustrating. For anyone who happens to see this and is working in ArcGIS Online, changing that setting in Map Viewer does work to stop the time from displaying. Maybe it's a bug? I found something that seems related, found in 11.4: "The ArcGIS Experience Builder Table widget fails to hide the time for a date field when 'Show time' is disabled on that field, and the list of fields for the widget is customized." BUG-000174261 for ArcGIS Experience Builder
Thank you, that's useful to know!