Page 1 of 1
DecimalToString Eliminating Right Zeros
Posted: Tue Mar 23, 2010 6:14 am
by myukassign
Hi ,
I have values coming like this. My datatype is Decimal(5,2)
00023.0200
00035.20
I am using the following function and assing to a Varchar field.
DecimalToString(MyVar,"suppress_zero")
The issue is first value it fine..my result is 23.02
Second value is killing my peace, its coming like 35.2
Can anyone give me a tip to keep that leading zero and get value like this 35.20
Many thanks in advance
Posted: Tue Mar 23, 2010 7:05 am
by gssr
What is your Job Flow?
Is your source file is any database or sequential file?
What datatype you are going to load that column (Decimal or String)?
Posted: Tue Mar 23, 2010 9:19 am
by Sainath.Srinivasan
Or how about
Code: Select all
yourString[1,1] : Trim(yourString[2,9999], '0', 'L')
Posted: Tue Mar 23, 2010 9:24 am
by Sairam
Left('00' :DecimalToString(MyVar,"fix_zero,suppress_zero"),2)
Let me know if it works
Posted: Tue Mar 23, 2010 9:41 am
by Sairam
Sairam wrote:Left('00' :DecimalToString(MyVar,"fix_zero,suppress_zero"),2)
Let me know if it works
Please find the correct expression
Left('00' :DecimalToString(MyVar,"fix_zero,suppress_zero"), Len(MyVar))
Re: DecimalToString Eliminating Right Zeros
Posted: Wed Apr 28, 2010 1:43 am
by ruf888
I have had the same problem as you and searched the forum for a solution but cannot find anything which did work. I made several tests by myself and have found out a solution which will work for keeping the zeros after decimal as well as the original digits after the decimal :
Suppose we have 2 values :
23,00
25,12
We must use a function which will keep the 12 after decimal and for the 00 :
I used the following formula :
IF Index(DecimalToString(Price,"fix_zero,suppress_zero"), '.',1)=0 THEN
DecimalToString(Price_If,"fix_zero,suppress_zero") : '.00' ELSE DecimalToString(Price_If,"fix_zero,suppress_zero")
With this formula we get the decimal value as char
23.00
25.12
I hope this will help all who are having the same problem.