TO NUMBER

From Oracle FAQ
Jump to: navigation, search

TO_NUMBER is a SQL function used to convert a string to a NUMBER value.

[edit] Syntax

The syntax for the TO_NUMBER function is:

to_number( string, [ format_mask ], [ nls_language ] )

Where:

  • string is the string that will be converted to a number.
  • format_mask is optional. This is the format that will be used to convert the string to a number.
  • nls_language is also optional. This is the NLS language (regional settings) used to convert the string to a number.

[edit] Examples

SQL> SELECT TO_NUMBER('$1234.56', '$9999.99') FROM dual;
TO_NUMBER('$1234.56','$9999.99')
--------------------------------
                         1234.56

[edit] Also see

  • TO_DATE, function to convert a string to a date.
  • TO_CHAR, function to convert a number or date to a string.