Logo

TRUNC

Updated 2023-10-20 15:36:08.687000

Syntax

SELECT [westclintech].[wct].[TRUNC] (
  <@Number, float,>
 ,<@Num_digits, float,>)

Description

Use the scalar function TRUNC to truncate a number to an integer by removing the fractional part of the number.

Arguments

@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.

@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.

Return Type

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.

Examples

select wct.TRUNC(123456.789, -4);

Here is the result set.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"120000"}]}