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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert string to text

Status
Not open for further replies.

bryan3473

MIS
Sep 25, 2003
21
US
Good morning all, ok im trying to convert a string to a numerical value. The problem I am having is that the number has 2 dashes in it. Example and this is always the same 0500-010-95. Is there any way i can change this to a number value so i can create a grouping. The first set is the main the second set is sub-account and the third is department. I am using CR 8.5. I tried converting to a number using the ToNumber({mystringfield}) but it told me it was not a numerical value.

Thanks a lot.

Bryan
Bmcafee@regio-tile.com
 
A formula to return the "Main":
{your_field}[1-4]

A formula to return the sub-accnt:
{your_field}[6-8]

A formula to return the Dept:
{your_field}[10-11]

You can of course convert the resulting strings to numbers.

hth,
- Ido


Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
ok stupid question but do i creat 3 different formulas cause the string is all one field xxxx-xxx-xx.

 
Yes, 3 formulas.

You then group at level on the 1st formula, at level 2 on the 2nd formula, etc.

Cheers,
- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
You could use:

tonumber(replace({table.string},"-",""))

-LB
 
im not quite sure i understand that formula could you expand a little

here is what i got so far tonumber(replace{@leftaccount} then im a little lost.
 
Just substitute your stringfield for {table.string}. If your string field results in 0500-010-95, this formula would return a number: 50001095. Note that you lose the leading zero when you convert it to a number (which is what you said you wanted to do in your original post).

I wonder though whether you realize you could just insert a group on your stringfield without converting it to a number?

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top