Saturday, October 8, 2011

SQL Round To Quarter


This is a reminder to myself how to round to the nearest fraction, in this case a quarter.
Next time I won't spend 15 minutes trying to recall the rounding formula. I'll just look it up here.

DECLARE @target smallmoney
SET @target = 597.80


--round to quarter hourSELECT ROUND( @Target/25.0, 2) * 25

-- Result = 597.75



(Originally posted 8/3/2007)

No comments:

Post a Comment