Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server MROUND function


MROUND
 
Updated: 17 August 2010
Use MROUND to calculate a number rounded to the desired multiple.
Syntax
SELECT [westclintech].[wct].[MROUND] (
   <@Number, float,>
 ,<@Multiple, float,>)
Arguments
@Number
is the number to rounded up. @Number is an expression of type float or of a type that can be implicitly converted to float
@Multiple
is the multiple to which the number is to be rounded. @Multiple is an expression of type float or of a type that can be implicitly converted to float
Return Types
float
Remarks
·         MROUND rounds up, away from zero, if the remainder of dividing number by multiple is greater than or equal to half the value of multiple.
Example
 
select wct.MROUND(21,5)
 
Here is the result set
----------------------
20
 
(1 row(s) affected)
 
The following example illustrates how to use the MROUND function with dates and times, by rounding a date and time to the nearest 15 minutes:
 
select cast(wct.mround(cast(cast('2008-10-23 13:02:24.030' as datetime) as float), cast(cast('00:15:00' as datetime) as float)) as datetime)
 
Here is the result set
 
-----------------------
2008-10-23 12:59:59.997


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service