views:

847

answers:

3

I'm working with MS Access to do some math. I'm taking a Cost and Dividing it by a decimal value to get a Price. I'm using a link table and a access sql query.

SQL Ex

Select (cost/markup) As Price From T_Cost;

Calulcation Ex. 1234 / .55 = 2243.6363 1000 / .50 = 2000

I'm trying to figure out a way to remove the decimal places that will work when there are decimals and when there are not.

I was thinking of doing something like this in my Access SQL:

Mid("2243,6363", 0, Instr("2243,6363","."))

But this won't work if there is not a decimal place.

+3  A: 

To remove the numbers after the decimal point:

Int(number)

or in your case

Int(cost/markup)

New SQL is:

Select Int(cost/markup) As Price From T_Cost;
Robert Harvey
+2  A: 

Use Round. That's what it's designed for. However I'm curious. Why wouldn't you want the cents?

Tony Toews
FYI, the Round function in Access uses "Banker's Rounding."
Robert Harvey
The number format I am using is similiar to Japanese Yen so there are no cents. Like 150 Yen would be similar $1.50.
MaxGeek
Ok, you don't need to worry about the decimal places then. However, in my opinion, you should still use Round instead of Int as that would be more accurate overall.
Tony Toews
A: 

Thaks man!!! it works great...

Vari
What works great?
David-W-Fenton