mbroad02
asked on
Crystal How to split 9-char zip
I have a 9-character zip-code that I would like to be able to split into the format zipfirst5-ziplast4.
How do I code this in a Crystal formula?
Thanks
How do I code this in a Crystal formula?
Thanks
totext(left(zip,5))+"-"+to text(right (zip,4))
you might not need the totext if the zip is a string
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If your zip code is a string, are all of them 9 digits, or do you have some 5 digit zip codes? If you use Picture and some of your zip codes are only 5 digits, you'll get a "-" at the end. You can avoid that by using:
if Length ({zip code field}) > 5 then
Picture ({zip code field}, "xxxxx-xxxx")
else
{zip code field}
James
if Length ({zip code field}) > 5 then
Picture ({zip code field}, "xxxxx-xxxx")
else
{zip code field}
James
ASKER
Since the zip-9 is a string, the Picture({ZipField},"xxxxx- xxxx") formula worked perfectly.
Thank you!!
Thank you!!