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

Formating Number

Status
Not open for further replies.

zrazzaq

MIS
Apr 13, 2005
102
US
Hi:
I have a query that outputs an amount and name. The amount shows up like this 1222.45698 and I need it to NOT round off but need two decimal places. 1222.45 and no commas in between the numbers. How can I write the query to do this format.
Thanks
Z
 
Try this
Code:
Format( Int([Amount]*100)/100, "0.00")
 
Thanks Golom...it did work but it throws my calculation off for some reason. Ok how about this can I in vb code find where the decimal is and just have two numbers right of the deciamls.
For example:
657.3375
just be 657.33
75 falls off
thanks
Z
 
You are probably using a float data type (i.e. double or single). Those data types are approximations only which means that not every decimal number can be exactly represented. You should try the currency data type which is handled as an integer with a floating decimal point (max of 4 digits after the decimal.) From the previous example
Code:
cCur ( Format( Int([Amount]*100)/100, "0.00") )

If however, you are doing arithmetic with some other value and that other value is a float then VB may still convert to a float before doing the math. You may need to manually control the data type conversion to ensure that the math is done on Currency data types.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top