Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server TRUNC function


TRUNC
 
Updated: 17 August 2010
Use TRUNC to truncate a number to an integer by removing the fractional part of the number.
Syntax
SELECT [westclintech].[wct].[TRUNC] (
   <@Number, float,>
 ,<@Num_digits, float,>)
Arguments
@Number
is the value to be truncated. @Number is an expression of type float or of a type that can be implicitly converted to float
@Num_digits
is the number of digits to be truncated. @Num_digits is an expression of type float or of a type that can be implicitly converted to float
Return Types
float
Remarks
·         TRUNC might appear to behave like the INT function, but INT rounds numbers down to the nearest integer based on the value of the fractional part of the number. TRUNC and INT will diverge for negative numbers.
·         If @Num_digits is greater than 0 (zero), then number is truncated at the specified decimal place.
·         If @Num_digits is 0, then number is truncated.
·         If @Num_digits is less than 0, then number is truncated to the left of the decimal point.
Example
 
select wct.TRUNC(123456.789, -4)
Here is the result set
----------------------
120000
 
(1 row(s) affected)


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service