Hi
I need to pad zeros on the left side of a varchar field. e.g:
I have a field called ID with length 6. Now if it is populated with 12,the it should come as 000012 and if 123 is populated then it should come as 000123. Please let me know if it is possible and how to implement........
Regards
Arnie.
attaching zeros on left side.
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 101
- Joined: Mon Aug 13, 2007 2:32 am
Arnie, this was discussed in another current thread. The VarChar() function to use is PadChar()
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 36
- Joined: Mon Jul 16, 2007 3:37 am
- Location: USA
Re: attaching zeros on left side.
Hai ,
First u take two stage variables like stg1,stg2 .logic in stage varibles is
stg1=6-len(dslink.input)
stg2=str('0',stg1):dslink.input
Present i have no datastage ,i am sending this logic without checking ,try the logic if u get any problem send it to me.
First u take two stage variables like stg1,stg2 .logic in stage varibles is
stg1=6-len(dslink.input)
stg2=str('0',stg1):dslink.input
Present i have no datastage ,i am sending this logic without checking ,try the logic if u get any problem send it to me.
VINOD
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
ArndW, I doubt if there is any inbuild function called PadChar() available. Did you mean to say PadString()?
That function is not the best fit to this requirement (Left side / Beginning Padding).
Str() function can be used directly without stage variable specification:
That function is not the best fit to this requirement (Left side / Beginning Padding).
Str() function can be used directly without stage variable specification:
Code: Select all
Str("0", 6 - Len(Input.ID)):Input.ID (Trim the input field if required)
ArndW wrote:Arnie, this was discussed in another current thread. The VarChar() function to use is PadChar() ...
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 101
- Joined: Mon Aug 13, 2007 2:32 am