I would like to create an expression using the field calculator in ArcMap to be able to convert an Int field to a string and add leading zeroes.
I am able to do it in a python window with an example
x=450
print str(x).zfill(4)
>>>0450
I have tried:
!Time!.str().zfill(4)
but that gives me invalid syntax errors.
-
Here is a similar question answered earlier today: gis.stackexchange.com/questions/129927/…juturna– juturna2015年01月12日 20:18:01 +00:00Commented Jan 12, 2015 at 20:18
1 Answer 1
str
is a class, not a method, so you need to do:
str(!Time!).zfill(4)
This should work if the Time
field is an integer. If it's a float
or other type, you will need to recast it as an int
.
Explore related questions
See similar questions with these tags.