Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1185
  • Last Modified:

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.
0
DanielAttard
Asked:
DanielAttard
1 Solution
 
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
 
QlemoC++ DeveloperCommented:
Just replace your 1000's with 4000's to get the expected result:
            Int( (999000*1.2) / 4000 + 0.5 ) * 4000
0
 
Gustav BrockCIOCommented:
You can simply use:

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

Then

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

/gustav
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now