Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding help needed - I thought this was simple.

Status
Not open for further replies.

gtarrant

Technical User
Jul 29, 2001
43
US
I have a situation that has left me feeling like a complete newbie. I've even tried to research this on the internet, but haven't located anything on it.

Here's my problem:

I'm trying to round a salary amount to a thousand, trying to always round up. So, for instance, if someones salary was $40,000.01 I would like the return to read $41,000.00

I've used the Round Function ROUND(SALARY,-3)and I've even tried ROUND(CEILING(SALARY),-3)but this doesn't seem to work for what I need and tends to round down.

What's the secret? Is this something so ovious that it's not listed on the internet due to its generality? HELP!
 
What's wrong with using ceiling by itself without the round function?

Questions about posting. See faq183-874
 
I've tried that also, but it seems to only go up by a dollar - see below.

60665.28 60666
63394.24 63395

I need it to go up to a thousand.
 
Kinda unusual... what about:
Code:
select ceiling( value/1e3) *1e3
 
Thanks vongrunt!!!! I'm glad to see a programmer say this was unusual - now I don't feel like such an idiot.

It works perfectly and is exactly what I need. Thanks again.
 
I barely remember when I used ceiling()/floor() in applications last time... especially over thousands. Too much round() stuff I think :(
 
I didn't even know about ceiling, honestly. But I typically use floor() all the time in my VB programming [Int()].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top