INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

PADL

PADL

(OP)
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

RE: PADL

In Foxpro it would be:

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

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

Rob.

RE: PADL

(OP)
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


RE: PADL

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

RE: PADL

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 ing

RE: PADL

Griff,

The first aTemp(t) looks the most Right to me winky smile

Thnx
TonHu

RE: PADL

Very good TonHu!

Gotta have a chuckle once in a while!

Martin

Regards

Griff
Keep ing

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close