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
DecimalToString Eliminating Right Zeros
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 238
- Joined: Fri Jul 25, 2008 8:55 am
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Or how about
Code: Select all
yourString[1,1] : Trim(yourString[2,9999], '0', 'L')
Re: DecimalToString Eliminating Right Zeros
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.
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.