Formula: LeftPad() , RightPad()
Category: String
LeftPad()
Pads text from the left
It’s kind of like saying...
Hey Coda, will you add extra values to the left of this text?
RightPad()
Pads text from the right
Or put another way...
Hey Coda, will you add extra values to the right of this text?
LeftPad() and RightPad() take three parameters. Two are required and one is optional:
Required
Text
PadLeft(Text, TargetLength, PadString)
The value that you want to pad.
Required
TargetLength
PadLeft(Text, TargetLength, PadString)
The length of the value after it's padded.
Optional
PadString
PadLeft(Text, TargetLength, PadString)
The text to pad your values with.
Both formulas pad or add extra characters to a string if that string is not the desired length. This formula is best learned within an example.
A consulting business sends out invoices to their clients. For the sake of consistency, they want their invoice numbers to always be the same number of characters in length. LeftPad() and RightPad() allow this consulting firm to ensure that every invoice stays consistent.
Play with the invoice creator below to see how this formula works. No matter how big you make the invoice number, it will alway be 5 characters long.
Invoice should be characters long