Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to TRANSFORM a number? 2

Status
Not open for further replies.

dsandlin

Programmer
Jul 11, 2003
56
0
0
CR
I have tried to decipher the help file on the TRANSFORM function, but have failed to figure out how to do the simplest thing. I want to convert a number into a string with four digits using leading zeroes.

There are no examples on how to use the format codes (e.g., @L).

What is the format to turn 3 into '0003'?

Is it really necessary to use something like
RIGHT('0000000' + ALLTRIM(STR(3)), 4)?
That seems like overkill with a performance hit to me.

Does anyone know of a good reference for the TRANSFORM function?


Regards, Dick
 
You can also use PADL(3, 4, "0") to get the same results.
 
One way "to turn 3 into '0003'"...

Code:
 mnThree = 2
 mcThree = PADL(ALLTRIM(STR(mnThree)),4,"0")

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Dick,
You were close, try:
Code:
?TRANSFORM(3,"@L 9999")
Rick
 
Thanks, Rick, for the answer that I was looking for. I gave you a star for that one.

Now, does anyone know of a good reference for finding that kind of information? (outside of Tek-Tips - which is rapidly becoming my favorite reference for all questions...)

Mark, JRB, and Mike, thanks for good alternate solutions. I was trying to find a way to avoid more than one function call. Mike, you cut it down to two at least -- pretty close.


Regards, Dick [reading]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top