Hi,
My requirement is such that I need to append zeros with my input file. The output length is 5. I might get an input from 1 length to 5 length. Say the input 'ABC' (length 3)
Input='ABC'
Output='ABC00'
Then my output must append two zeros. length of input is 4, then 1 zero needs to be appened..
'Kindly help me
Appending the spaces with Zero
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 42
- Joined: Mon Apr 21, 2008 1:49 am
LEFT(In.InputColumnName:'00000',5) should do the trick for you assuming your datatype is CHAR or VARCHAR
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 12
- Joined: Wed Jul 25, 2007 6:56 am
- Location: Hyd
If the string is length is more, say 50 then following can be used
Thanks,
Satish
Code: Select all
TrimLeadingTrailing(In.InputColumnName):PadString('','0',50-len(TrimLeadingTrailing(In.InputColumnName)))
Thanks,
Satish
Why not just "LEFT(In.InputColumnName:STR('0',50),50)" - simpler and uses somewhat less CPU?
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 42
- Joined: Mon Apr 21, 2008 1:49 am
-
- Participant
- Posts: 46
- Joined: Tue Aug 21, 2007 5:39 am
- Location: Bangalore, India
Create a routine with the following code. Call the routine in wherever required.
if Len(In.InputColumnName) = 2 Then Ans = In.InputColumnName:'000'
else if Len(In.InputColumnName) = 3 Then Ans = In.InputColumnName:'00'
else if Len(In.InputColumnName) = 4 Then Ans = In.InputColumnName:'0':
else Ans = In.InputColumnName
if Len(In.InputColumnName) = 2 Then Ans = In.InputColumnName:'000'
else if Len(In.InputColumnName) = 3 Then Ans = In.InputColumnName:'00'
else if Len(In.InputColumnName) = 4 Then Ans = In.InputColumnName:'0':
else Ans = In.InputColumnName