Padding Zero's to the left of an integer

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
suchit1983
Participant
Posts: 9
Joined: Thu Nov 29, 2007 10:45 pm

Padding Zero's to the left of an integer

Post by suchit1983 »

Hi,

How to pad zero's to the left of an integer?

I have 2 inputs Id1(Integer 21) and Id2(Integer 4)
I want the output as Id3(Integer 25)

Logic for Id3 : Concat Id1 and Id2

If Id2 = 24, my output should be Id1:0024
If Id2 = 235, my output should be Id1:0235

Please provide a approach for this.
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Re: Padding Zero's to the left of an integer

Post by pavankvk »

suchit1983 wrote:Hi,

How to pad zero's to the left of an integer?

I have 2 inputs Id1(Integer 21) and Id2(Integer 4)
I want the output as Id3(Integer 25)

Logic for Id3 : Concat Id1 and Id2

If Id2 = 24, my output should be Id1:0024
If Id2 = 235, my output should be Id1:0235

Please provide a approach for this.
Try

Str function. follow the syntax.

Str('0',(4-Len(Id2)):Id2)
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Re: Padding Zero's to the left of an integer

Post by pavankvk »

suchit1983 wrote:Hi,

How to pad zero's to the left of an integer?

I have 2 inputs Id1(Integer 21) and Id2(Integer 4)
I want the output as Id3(Integer 25)

Logic for Id3 : Concat Id1 and Id2

If Id2 = 24, my output should be Id1:0024
If Id2 = 235, my output should be Id1:0235

Please provide a approach for this.
Try

Str function. follow the syntax.

Str('0',(4-Len(Id2)):Id2)
suchit1983
Participant
Posts: 9
Joined: Thu Nov 29, 2007 10:45 pm

Post by suchit1983 »

Thanks a lot Pavan...
Post Reply