Skip to main content
Known Participant
May 14, 2009
Answered

how to do this in coldfusion

  • May 14, 2009
  • 1 reply
  • 827 views

hi i had insert statement and the statement is

<cfqueryparam value="#right(trim(items[1]),13)#" cfsqltype="cf_sql_varchar">,  

i need to do padding for this because we had some values of length 4(ex:1234),some have lenght 5(ex:12345),so i need to make them all to lenght of 13 by usig padding (ex:0000000001234),

how can i do this in coldfusion.

This topic has been closed for replies.
Correct answer ilssac

LJustify() and RJustify() functions allow you to space pad strings to a desired length.

Then a simple Replace() function allows you to change those spaces into another character.

I.E.

<cfoutput>#replace(LJustify("1234",13)," ","0","ALL")#</cfoutput>

1 reply

ilssac
ilssacCorrect answer
Inspiring
May 14, 2009

LJustify() and RJustify() functions allow you to space pad strings to a desired length.

Then a simple Replace() function allows you to change those spaces into another character.

I.E.

<cfoutput>#replace(LJustify("1234",13)," ","0","ALL")#</cfoutput>

Inspiring
May 14, 2009

another way

newstring = right("0000000000000" & oldstring, 13);