Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Social security number formatting Post Reply Post New Topic
Author Message
TorLang
Groupie
Groupie


Joined: 13 Jun 2012
Location: United States
Online Status: Offline
Posts: 50
Quote TorLang Replybullet Topic: Social security number formatting
    Posted: 26 Jul 2012 at 8:54am
here is the scenario:
In the database (hospital patient data) I am running report against, the social security numbers coming out of the table are in this format:

230,901,438 (I know, its insane. The field is also a number)
which after applying this:
Picture (ToText ({TSM040_PERSON_HDR.soc_scu_no}, 0, ""), "xxx-xx-xxx")

comes out nicely as 230-90-1438

Here is the problem though: If the SSN starts with a zero, it looks like this:
70,401,384

which translates to (after applying the formatting):
704-01-384 which is not good.

So my problem is how do I format this thing if it starts with a zero, or two zero's? Any ideas would be much appreciated.

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 26 Jul 2012 at 9:10am
local stringvar x = right("00" + totext({table.field}, 0, ""), 10)
picture(x, "xxx-xx-xxxx")
 
should work
IP IP Logged
TorLang
Groupie
Groupie


Joined: 13 Jun 2012
Location: United States
Online Status: Offline
Posts: 50
Quote TorLang Replybullet Posted: 26 Jul 2012 at 9:22am
local stringvar x = right("00" + totext({TSM040_PERSON_HDR.soc_scu_no}, 0, ""), 10)
picture(x, "xxx-xx-xxxx")

Get an error that point out that:
picture(x, "xxx-xx-xxxx")

is not part of the formula. I am looking for a missing bracket or paranthesis, but don't see any. Any suggestion...
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Jul 2012 at 9:22am
if for some reason lockwelle's answer does not cover it all this should handle it even if it is all all zeros...
 
picture(totext({TSM040_PERSON_HDR.soc_scu_no},'000000000',0,''),'xxx-xx-xxxx')
 


Edited by DBlank - 26 Jul 2012 at 9:33am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 26 Jul 2012 at 9:24am
put a ; after the first line...silly me
sorry bout that
IP IP Logged
TorLang
Groupie
Groupie


Joined: 13 Jun 2012
Location: United States
Online Status: Offline
Posts: 50
Quote TorLang Replybullet Posted: 26 Jul 2012 at 10:04am
yep that did it. Wished I had 5 years of Crystal Coding experience instead of 5 months. Thanks a lot, guys, for the quick replies...
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.000 seconds.