Skip to content

TO_NUMBER

TO_NUMBER(char_value, [format_mask], [nls_language])

Section titled “TO_NUMBER(char_value, [format_mask], [nls_language])”
  • char_value: It is the character string that will be converted to a number. This character string typically represents a numeric value in a particular format.
  • format_mask: This optional parameter specifies the format that will be used to interpret char_value. It consists of a series of characters which represent a date format. If this parameter is not provided, the char_value is interpreted using the default number format.
  • nls_language: Another optional parameter, which specifies the language in which the number is represented. If this parameter is not provided, the default language for the session is used. This can change the way certain elements are interpreted, like decimal separators or group separators.
SELECT TO_NUMBER('1000.10', '9999.99') as TO_NUMBER_Example
FROM dual;
TO_NUMBER_Example
-----------------
1000.1

The TO_NUMBER function in Oracle converts a text or expression into a number. The first parameter of TO_NUMBER is the expression to convert, and the second parameter is a format model that defines the format of the number. In this example, the string '1000.10' is being converted to the number 1000.1 using the pattern '9999.99'.