MaxGeek
MaxGeek

Reputation: 1105

Remove Decimal Places with Access SQL Query

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.

Upvotes: 2

Views: 16896

Answers (2)

Tony Toews
Tony Toews

Reputation: 7882

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

Upvotes: 5

Robert Harvey
Robert Harvey

Reputation: 180858

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;

Upvotes: 5

Related Questions