Solved

# Round to nearest number - Divisible by 4,000

Posted on 2012-08-15
1,106 Views
I am using the following formula to round the resulting number to the nearest 1,000:

``````Int(((999000*1.2)/1000)+0.5)*1000
``````

I need to modify this formula so it rounds to the nearest number divisible by 4,000.

0
Question by:DanielAttard

LVL 65

Expert Comment

<T-SQL>

Give this a whirl...

Declare @num numeric = 5538354.25

SELECT CAST(ROUND(@num / 4000,0) as int) * 4000

Let us know if you're asking for this as an Access query expression, SQL Server T-SQL, or Excel expression.
0

LVL 68

Accepted Solution

Just replace your 1000's with 4000's to get the expected result:
Int( (999000*1.2) / 4000 + 0.5 ) * 4000
0

LVL 48

Expert Comment

You can simply use:

RoundedUp: -Int(-999000*1.2/1000)*1000

Then

RoundedUp4000: -Int(-999000*1.2/4000)*4000

/gustav
0

## Featured Post

### Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…