Round to nearest number - Divisible by 4,000

I am using the following formula to round the resulting number to the nearest 1,000:

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

Open in new window


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

Thanks for your help.
DanielAttardAsked:
Who is Participating?
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Just replace your 1000's with 4000's to get the expected result:
            Int( (999000*1.2) / 4000 + 0.5 ) * 4000
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
<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
 
Gustav BrockCIOCommented:
You can simply use:

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

Then

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

/gustav
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.