Function Reference > Functions > TO_DECIMAL
  

TO_DECIMAL

Converts a string or numeric value to a decimal value. TO_DECIMAL ignores leading spaces.

Syntax

TO_DECIMAL( value [, scale] )
Argument
Required/
Optional
Description
value
Required
Must be a string or numeric datatype. Passes the values you want to convert to decimals. You can enter any valid expression.
scale
Required or Optional
Must be an integer literal between 0 and 28, inclusive. Specifies the number of digits allowed after the decimal point. If you omit this argument, the function returns a value with the same scale as the input value.
You cannot omit this argument in an elastic mapping.

Return Value

Decimal of precision and scale between 0 and 28, inclusive.
0 if the value in the selected column is an empty string or a non-numeric character.
NULL if a value passed to the function is NULL.

Example

This expression uses values from the column IN_TAX. The data type is decimal with precision of 10 and scale of 3:
TO_DECIMAL( IN_TAX, 3 )
IN_TAX
RETURN VALUE
'15.6789'
15.679
'60.2'
60.200
'118.348'
118.348
NULL
NULL
'A12.3Grove'
0