Friday, August 03, 2007

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 hour
SELECT ROUND( @Target/25.0, 2) * 25

-- Result = 597.75