String to Numeric Conversion

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
anandkumarm
Premium Member
Premium Member
Posts: 55
Joined: Tue Feb 24, 2004 8:17 am

String to Numeric Conversion

Post 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
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Num("3,990") evaluates to false, so you took your else clause. Num does not consider the comma as a numeric character.
Post Reply