Page 1 of 1
trim the data leading zero
Posted: Mon Mar 22, 2010 2:05 pm
by sreddy
Hi
My source data is like this.
000000001
000008753
000026843
000000084
I need the out put data as
1
8753
26843
84
i want to trim leading 0 . how can i do it.
At present i am applying the trim like this, it is not working.
Lnk1.VEND_NUM = Trim(Lnk1.VEND_NUM, "0", "F")
Please correct me.
Thanks
SReddy
Posted: Mon Mar 22, 2010 2:07 pm
by anbu
What is the output you are getting?
Posted: Mon Mar 22, 2010 2:11 pm
by sreddy
No coversion
same in the source. trim is not working.
000000001
Posted: Mon Mar 22, 2010 2:13 pm
by anbu
Code: Select all
Lnk1.VEND_NUM = Trim(Lnk1.VEND_NUM, "0", "L")
L Removes leading occurrences of character
You have to use L option in Trim command
Posted: Mon Mar 22, 2010 8:55 pm
by chulett
... and your target, Lnk1.VEND_NUM, is what data type? Guessing... not a string.
Posted: Tue Mar 23, 2010 1:10 am
by rohithmuthyala
Convert the source data from string to decimal...automatically the zero's will be stripped off. If you still want the source data to be string then convert it back from decimal to string..!
Posted: Tue Mar 23, 2010 3:09 pm
by Kryt0n
rohithmuthyala wrote:Convert the source data from string to decimal...automatically the zero's will be stripped off. If you still want the source data to be string then convert it back from decimal to string..!
Have you tried that for yourself? You may just find it is the decimal causing the zeroes... and as Craig has hinted at, the OP needs to consider making his target type a String
Posted: Tue Mar 23, 2010 4:02 pm
by Sairam
Kryt0n wrote:rohithmuthyala wrote:Convert the source data from string to decimal...automatically the zero's will be stripped off. If you still want the source data to be string then convert it back from decimal to string..!
Have you tried that for yourself? You may just find it is the decimal causing the zeroes... and as Craig has hinted at, the OP needs to consider making his target type a String
Assumption:
The Incoming Field is Decimal and output is Varchar
Try this expression
DecimalToString(inCol,"suppress_zero")
If the Incoming Field is not Decimal ,try converting to Decimal [/img]
Posted: Tue Mar 23, 2010 10:57 pm
by BMSK
use Abs() function
regards
BMSK
Posted: Wed Mar 24, 2010 3:27 am
by Sainath.Srinivasan
Trim does not work because default casting to string brings the sign as first character - which will be space for positive.
Posted: Wed Mar 24, 2010 6:20 am
by datisaq
In these scenarios you need to mention the data type(source/target).
Source: string Target: string Result: trim(col_name,'0','L') will work
Source: decimal Target: string
Result: DecimalToString(col_name,'suppress_zero') will work
Note:- trim(DecimalToString(col_name),'0','L') will not work as Sainath mentioned the problem below.
DSExperts / Sainath can you guys please be more elaborative on the above trim issue will be really great !!!
Posted: Wed Mar 24, 2010 7:16 am
by chulett
I don't understand why people feel the need to come in and repeatedly
speculate on what the answer
might be without full disclosure of the issue from the original poster.
I don't know about anyone else but I was planning on waiting for sreddy to come back before continuing this. Didn't
quite work out but...
fades back into the darkness...
![Wink :wink:](./images/smilies/icon_wink.gif)