Page 1 of 1

String to Numeric Conversion

Posted: Wed Aug 11, 2004 8:49 am
by anandkumarm
Hi All,

In on of the postings I found the follwing solution mentioned for converting the String to Integer in Data Stage Server Canvas

"Code:
If Num(inlink.column) Then Iconv(inlink.column,"MD0") Else 0

The Iconv function will remove thousands delimiters and currency symbol. It will also round to the indicated number of decimal places and NOT return the decimal place holder character."


When I used this code for a value 3,990 it is returning a 0 but when I used the following code

A=Iconv(inlink.column,"MD0")
A+=0
If Num(A) Then Ans= A Else Ans=0

it is working fine.

I understand that when we add a zero or do an arithmetic operation the value is automatically converted to Numeric value but I am wondering why it didn't work with the first solution.

Thanks in advance for the replies,
Anand

Posted: Wed Aug 11, 2004 3:32 pm
by Mike
Num("3,990") evaluates to false, so you took your else clause. Num does not consider the comma as a numeric character.