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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding Up

Status
Not open for further replies.

onedunpark

IS-IT--Management
Jan 17, 2003
19
GB
This is going to be such an easy one, I'm sure, but I can't find anything about it elsewhere.

Is there a command (ideally I'd like to run this in a trigger) to allow me to round a value up to the nearest multiple of 5 (or whatever other whole unit I wish) (e.g., 12.5 gets rounded up to 15)

Sorry for the obviousness of the question, but I'm stumped, other than writing my own stored procedure (I think)

Any and all responses greatly appreciated.

Thanks

Steven
 
Hi

You could try and use the ROUND function but I don't think that it would let you round up in multiples of 5.
You might need to write a procedure or a function and use the ROUND function in there.

Have a look at ROUND in BOL

Hope this helps

John
 
I think you'll need to write it too. If you have SQL Server 2000, I'd write it as a user defined function rather than a stored procedure.
 
try ROUND(12.5/5, 0) * 5

you could change 5 to whatever other unit you wish, even decimals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top