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!

Converting String to a numeric value

Status
Not open for further replies.

jcrawford08

Technical User
Nov 19, 2008
71
US
to preface, running CR XI R1 in a SQL envirotnment...

I have a user who needs to track manual follow ups; she is prefacing a string field with a number (1-5) followed by an equal sign (=) and then some additional information.

I had planned on doing a split then on the string field at the equal sign and then converting it to a number, so that I can add it to another section that tracks automatic follow ups. But alas, the best laid plans go astray...

I get an error with the following line, indicating that the string is non-numeric...

tonumber (split({User.Comments},"=")[1])


I thought that in converting to a number, it would read the string as numeric, but apparently there's something I'm misunderstanding regarding its usage.

Any ideas or work-arounds to use?


Thanks!

Not in word only, but in deed also... 1Jn3:18
 
try something like this to check if the value is numeric before attempting to convert it to a number:

if isnumeric((split({User.Comments},"=")[1]))
then tonumber (split({User.Comments},"=")[1])


you could add an else clause also that would return a 0 or other # that would indicate a non-numeric value (ie: 999999999)
 
You might need a null check first, too.

-LB
 
Awesome guys - I threw the null check and the numeric check in and it worked like a charm :)

Not in word only, but in deed also... 1Jn3:18
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top