how to remove leading zeros for decimal values

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
dvpawankumar
Participant
Posts: 46
Joined: Fri Oct 06, 2006 6:36 am
Location: Tucson

how to remove leading zeros for decimal values

Post 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
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

What is your target datatype? String?
dvpawankumar
Participant
Posts: 46
Joined: Fri Oct 06, 2006 6:36 am
Location: Tucson

Post by dvpawankumar »

My target datatype is decimal only.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pprakash
Participant
Posts: 3
Joined: Thu Aug 09, 2012 11:14 am
Location: Bangalore

Re: how to remove leading zeros for decimal values

Post 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,
Prakash S Patil
Capgemini
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply