Page 1 of 1

how to remove leading zeros for decimal values

Posted: Mon Oct 22, 2007 4:38 am
by dvpawankumar
Hi All,

I need help on this.

Suppose I have value like 0000001.00000009

But in output i need the value like 1.00000009 (it mean i need to remove the leading zeros)

I specified trim as below
Trim(column,'0','L')

But it is working for only non-decimal values. For decimal values how it will be?


Please help on this.

Thanks
Pavan

Posted: Mon Oct 22, 2007 4:59 am
by balajisr
What is your target datatype? String?

Posted: Mon Oct 22, 2007 5:01 am
by dvpawankumar
My target datatype is decimal only.

Posted: Mon Oct 22, 2007 6:07 am
by ray.wurlod
Is this the same project as this post?
Leading zeroes are merely an artifact - they do not matter for data type Decimal.

Re: how to remove leading zeros for decimal values

Posted: Fri Oct 26, 2012 6:43 am
by pprakash
For the posted example: value 0000001.00000009
If we want the output as 1.00000009 the solution is given below with the logic;

USE THE LOCIG AS BELOW: (By using String function DecimalToString we can get the solution)
Field(DecimalToString(InputLink.xyz,"suppress_zero"),".",1):".":Field(DecimalToString(InputLink.xyz),".",2)

The above logic has two portions.
Firstly, the logic supress the leading zeros before the decimal point.
Secondly, it displays the values of after decimal values
The output will be ==> 1.00000009

Note:- let the data type be decimal coming from the input, but make it as Varchar while sending to output link with increase in the length

Hope this will solve your problem Pavan.

Thanks and Regards,

Posted: Fri Oct 26, 2012 7:19 am
by chulett
Well... three points.

1. I imagine Pavan solved this five years ago.
2. And by 'solved' I mean realized that they had no issue at all.
3. They already noted how to do it for "non-decimal values".

:wink: