Skip to main content
Inspiring
February 12, 2007
Answered

Convet SSN to numeric

  • February 12, 2007
  • 4 replies
  • 512 views
Is anyone aware of any code that will take an SSN and remove the hyphens so I can use it as a numeric value?

SSN: 222-22-2222

New 222222222

    This topic has been closed for replies.
    Correct answer weezerboy
    yes PAULKD, that worked great!

    Now can I take another number which is my locality code and

    put it at the beginning of the numericssn (NumSSN)

    Like this

    Chicago --The code is 71
    SSN is 259-95-9658

    So I need the end result to be 71259959658

    Excel would call it CONCATENATE...joining several strings into one string

    4 replies

    tclaremont
    Inspiring
    February 12, 2007
    Be careful when converting a SSN to numeric. Depending on what you are doing with the "number" it might strip away leading zeros.

    012345678 is a perfectly valid SSN, and converting it to numeric may very well leave you with 12345678, which loses the leading zero.
    Inspiring
    February 12, 2007
    Here's a sample using Replace with the scope set to replace all dashes. (adding one shows it can convert it to a number)

    <cfset SSN="111-22-3333">
    <cfscript>
    WriteOutput("SSN:" & SSN);
    new = Replace(SSN, "-", "", "all");
    WriteOutput("New: " & new + 1);
    </cfscript>
    weezerboyAuthorCorrect answer
    Inspiring
    February 12, 2007
    yes PAULKD, that worked great!

    Now can I take another number which is my locality code and

    put it at the beginning of the numericssn (NumSSN)

    Like this

    Chicago --The code is 71
    SSN is 259-95-9658

    So I need the end result to be 71259959658

    Excel would call it CONCATENATE...joining several strings into one string
    Participating Frequently
    February 12, 2007
    You could try