Select to view content in your preferred language

Insert colons and zeros to normalize a time field

695
4
Jump to solution
10-06-2022 12:00 PM
RichardPenman1
New Contributor II

I have a time field looks like: 1322Z

I need it to look like 13:22:00Z.

How do I insert colons and add zeros to represent the seconds?

After goofing with python and arcade for way too long, I'm asking for a lifeline

0 Kudos
2 Solutions

Accepted Solutions
suburbanMapper
New Contributor II

Hi Richard,

It appears that you are referring to a 'text' field. The below snippet may work for you assuming they are all the same length of characters. You will need to change 'test' to your attribute name.

Concatenate([left($feature.test, 2), mid($feature.test, 2, 2), "00Z"],":")

View solution in original post

DanPatterson
MVP Esteemed Contributor

since you tagged python as well.

Python parser, into a text field, replace 'fld' with the !YourFldName! with the surrounding !

fld = "1322Z"

"{}:{}:00Z".format(fld[:2], fld[2:4])
'13:22:00Z'

... sort of retired...

View solution in original post

4 Replies
JeffSilberberg
Occasional Contributor III
suburbanMapper
New Contributor II

Hi Richard,

It appears that you are referring to a 'text' field. The below snippet may work for you assuming they are all the same length of characters. You will need to change 'test' to your attribute name.

Concatenate([left($feature.test, 2), mid($feature.test, 2, 2), "00Z"],":")

DanPatterson
MVP Esteemed Contributor

since you tagged python as well.

Python parser, into a text field, replace 'fld' with the !YourFldName! with the surrounding !

fld = "1322Z"

"{}:{}:00Z".format(fld[:2], fld[2:4])
'13:22:00Z'

... sort of retired...
RichardPenman1
New Contributor II

Brilliant! Thank you.

0 Kudos