Select to view content in your preferred language

Text field --> Date field

448
4
08-17-2023 12:18 PM
Laura
by MVP Regular Contributor
MVP Regular Contributor

I am trying to populate a new layer based off of some old data I found. However, this one text field that is housing Date info is a little odd. There are spaces between everything and there is a "12:" after almost every entry. How do I get this into my new date field?

Laura_0-1692299867935.png

 

4 Replies
Robert_LeClair
Esri Notable Contributor

So the first thing to do is replace the 12: in your text field to be a valid (generic) time.  To do this, I calculated the existing text field using the Replace function:

Replace($feature.date_text, '12:', '12:00:00') - see first image below.

Then in the date/time field, I did another field calculation using the following function:

$feature.date_text - see second image below.

The date/time field now has a valid date/time value that shows 12 noon.


FieldCalc1.JPGFieldCalc2.JPG

0 Kudos
Laura
by MVP Regular Contributor
MVP Regular Contributor

Hm, didn't quite work for me. Not sure where all those 000s are coming from

Laura_0-1692303246177.png

 

0 Kudos
Robert_LeClair
Esri Notable Contributor

Hmmmm...that's strange.  Can you share the data with me so I may do some testing?  My email is rleclair at esri dot com

0 Kudos
Laura
by MVP Regular Contributor
MVP Regular Contributor

Sure

0 Kudos