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

Numeric Functions

Status
Not open for further replies.

dzdncnfsd

MIS
Jul 14, 2000
118
US
Is there a function that will convert a numeric field to a character field (similar to the DTOC() function) that will allow me to drop the decimal point when I pull data into a new table?
I tried "CHRTRAN(numfield,'.','')" but of course that doesn't work.
Thanks, [sig]<p>Gladys Clemmer<br><a href=mailto:gladys.clemmer@fifsg.com>gladys.clemmer@fifsg.com</a><br><a href= > </a><br> [/sig]
 
Try STR(numfield,12,2) - number with 12 characters, 2 characters are for decimal places. TRANSFORM(numfield,'999999999.99') makes the same result. I use often TRANSFORM(numfield,'999,999,999.99') in reports. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Gladys, do you want to: 1) simply drop the decimal point, or 2) drop the entire fractional portion (what follows the decimal point)?

1) strtran(str(numfield, 12, 2), &quot;.&quot;)

2) str(numfield, 12)
[sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
If you do not want the returned value to be padded with blank spaces try
alltrim(str(int(numfield))
[sig]<p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br>[/sig]
 
Thank You!! Thank You!! Thank You!!
Strtran(str(numfield, 12, 2), &quot;.&quot;) was the one I needed for what I am doing today and it worked!!
No one else in my office uses VFP, so it is so great to be able to turn to you guys for help.
Thanks again. [sig]<p>Gladys Clemmer<br><a href=mailto:gladys.clemmer@fifsg.com>gladys.clemmer@fifsg.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top