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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PADL 1

Status
Not open for further replies.

dlpastel

Programmer
Aug 8, 2002
114
US
I have a numeric value in a database field that is set up as 7,2 format (7 total length with decimal point at 2)

I am trying to change numeric values to a string.

For example I would like to change 148.32 to "0014832"
or 50.00 to "00005000"

It seems like I need to use a combination of STR() and
PADL() but I cannot seem to get PadL to work.
I tried this:
PadL(alltrim(str(mynumber)),4,"0")
but it does not seem to work.

Any ideas?

Thanks,
Dan
 
In Foxpro it would be:

padl(mynumber*10,8,'0')

I haven't got the clipper norton guides at hand here.

Rob.
 
Here is the code. I figured it out.

atemp2:= alltrim(str(p_price)) && First change the numeric to a string and trim off spaces

atemp2:= strtran(atemp2,".") && Next get rid of the decimal point

atemp2:= padl(atemp2,7,"0") && Next pad the left hand side with 0's

REPLACE &atemp WITH atemp2 && Finally, update the database


 
Hi, dlpastel

How about:

replace &atemp with strzero(int(p_price*100),7,0)

Jock

"For a complete list of the ways technology has failed to improve the quality of life, press 2" - Madeleine Kahn
 
I would have done it like this:

Code:
aTemp2 = PadL(alltrim(str(p_price*100,7,0)),7,"0")
or (for no good reason)
Code:
aTemp2 = Right("0000000"+alltrim(str(p_price*100,7,0)),7)


Regards

Griff
Keep [Smile]ing
 
Griff,

The first aTemp(t) looks the most Right to me ;-)

Thnx
TonHu
 
Very good TonHu!

Gotta have a chuckle once in a while!

Martin

Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top