Field Calculator

887
2
01-11-2013 05:18 AM
DustinHolt
Occasional Contributor
I'm trying to copy the 5-6-7 character in one field to another field, can anyone help me with this.  I used this
left( [Township_R], 2) to copy the first two characters but I'm stuck on the 5-6-7 characters.
Tags (2)
0 Kudos
2 Replies
MayaThomas
New Contributor
mid( [Township_R], 5, 3 ) ?
0 Kudos
MayaThomas
New Contributor
Sure. You can use the Python rjust() method. It pads it with spaces though, so use it carefully.

x = !Township_R!

x.rjust(width[, fillchar])

width = total string length after padding (be mindful of your field length)
fillchar (optional) = filler character, default is a space (leave this out if you want space)

So if a record in Township_R is [ABC] then running this with a width of 5 (x.rjust(5)) will create [  ABC].
0 Kudos