Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting digits in a field

Status
Not open for further replies.

vblack7770

Programmer
Apr 11, 2005
26
US
I am using CR 8.5 with an ODBC to the database. I would like to write a formula that would help me count the digits in the social security # field and return all records that have > or < 9 digits. Thoughts?
 
The following should give you the number of digits in the field, assuming no letters are mistakenly entered:

len(trim(replace({table.ssn},"-","")))

If there might be letters, then use:

stringvar ssn := trim(replace({table.ssn},"-",""));
numbervar i;
numbervar j := len(ssn);
numbervar cnt;

for i := 1 to j do(
if isnumeric(ssn) then
cnt := cnt + 1
);
cnt

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top