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 text to number 1

Status
Not open for further replies.

kmPremier

MIS
Mar 30, 2004
8
CA
Hello all,
I am using Crystal 7.0
I have a field that is representative of a Category and is actually a numeric Category, but the field is a string field.
What is happening is that I am unable to sort this information in order - ie) it is giving me 1, 10, 11, 2, 23, 5, etc...
Is there any formula that I could use that would convert this to a numeric field so that it would sort properly????

Any help would be greatly appreciated.
Thanks
 
You could use either:

val({table.numericstring})

Or,

tonumber({table.numericstring})

-LB
 
You might also use a SQL Expression so that the database does this rather than Crystal, but this is dependent upon the database used, which you didn't share.

An example for many SQL databases would be:

Cast(table.field as numeric)

This way the database will do all of the work, rather than Crystal, improving performance.

-k
 
Thank you so much!
the val({table.numericstring}) worked! I knew it had to be a simple formula, but I couldn't find it anywhere.
Thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top