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 gkittelson 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 Number

Status
Not open for further replies.

waslbs92

Programmer
Nov 18, 2002
5
US
I have a string field that is 100 bytes and need to convert it to a numeric value. is it as simple as creating a formula field and using tonumber(x) or is there something else i can do?

This field is used to sort data....


Thanks....
 
100 bytes isn't very meaningful depending upon how it's stored, do you mean 100 characters/digits? Is there a decimal precision?

And why would you need this converted to a number, it's an ID, right?

If it's for sortation, you can pad it with zeroes.

Also keep in mind that the answer may be Crystal and database version dependent so posting that might prove helpful.

This might help, but I'd suggest also posting example data and expected output rather than a quick text blurb:


-k
 
i am using crystal 8.0 and the field is 100 characters...
the values are always going to be numeric and there are is no decimal precision.

The character field is always passing a number from 1 to 1000. i am ordering by this field and it is incorrect..

ie...1,10,11,12,13.....19,2,21,22,....29,3,30,4,5,6..etc

I can not pad since the the values are passed using a ttx file...

thanks...
 
ToNumber(x) will work nicely. There are others such as val(x) or value(x).

Steve Phillips, Crystal Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top