cancel
Showing results for 
Search instead for 
Did you mean: 

How to pad zeros at the left?

Former Member
0 Kudos

Hi All,

I have requirement where

Input is 1234

and Output should be :-0000001234(6 Zeros at left).

Please let me knw how to do it.

Thanks,

Suraj

Accepted Solutions (0)

Answers (4)

Answers (4)

praveen_sutra
Active Contributor
0 Kudos

hi Suraj,

If you are sure its should be always prefixed with 6 zeros then u can use above mentioned method.

But if you are not sure about the input string lenghth than below udf will help.

s = "000000".substring(s.length()) + s;


where s= input value which is 1234 in ur example given.


hope this solves your problem.


thanks and regards,

Praveen T

Former Member
0 Kudos

This message was moderated.

former_member184720
Active Contributor
0 Kudos

if it's always 6 zero's then simply use concat function and append with a constant

former_member192343
Active Contributor
0 Kudos

Hi

let me visualize Hareesh's advice

Regards, Mikhail

engswee
Active Contributor
0 Kudos

Hi Suraj

You can use function FormatNum under Arithmetic.

Enter all zeroes up to the maximum length of your desired output - 10 for your case, and no decimals.

For more information on how patterns for FormatNum works, you can refer to the below link for Java DecimalFormat.

DecimalFormat (Java Platform SE 7 )

Rgds

Eng Swee