I have a field named "ZIP" which has the zip code information for numerous records. Some of them have 9 numbers, but I only want them to have the first 5. What should my Pre-Logic Script look like to Field Calculate removing the last 4 numbers in this field?
Here is an image of the Field Calculator and the field:
Best Answer
Use the string indices. Instead of creating a whole function, just do something like:
!ZIP![:5]
--> basically grab everything from 0 index up to but not including the 5th index.So it only grabs the indices 0,1,2,3,4.
Check out this tutorial for more information.
If there are more than 5 it will just grab the first 5. If there are 5 exact, it will grab them.