cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Pad field with zero

heidi_andrew
Contributor

How can i take a sql result field where I am counting the number of people in the file for a trailer and left pad with zeroes? I have tried a bunch of the expressions shown in several of the answers here but nothing is working. I get
image

1 ACCEPTED SOLUTION

It is because the COUNT is an integer, try with this:

"0000000000".slice($COUNT.toString().length) + $COUNT

View solution in original post

10 REPLIES 10

AleksandarAngel
Contributor III

Hi @heidi.andrew,

You can try with the following expression:

"0000000000".slice($COUNT.length) + $COUNT

Let me know if this helps you.

BR,
Aleksandar.

Or if you want to do it in more dynamic way where you specify how long should the field be, you can try the following expresssion:

sl.range(0,10).map(x=>'0').join('').slice($COUNT.length) + $COUNT

Just change the second parameter in sl.range(0,x) .

I KEEP getting the null:

image
But i did figure out how to show first day of last month and last day of last month!

It is because the COUNT is an integer, try with this:

"0000000000".slice($COUNT.toString().length) + $COUNT