to_number()

A function for converting a numeric string into the NUMERIC datatype

to_number() is a system function for converting the string representation of a number into the NUMERIC datatype using the specified format.

to_number() was added in PostgreSQL 7.0.

Usage

to_number ( text, text ) → numeric

to_number() converts the provided string into a NUMERIC value using the specified format; see the PostgreSQL documentation section Template Patterns for Numeric Formatting for details.

Change history

Examples

Basic usage example for :

postgres=# SELECT to_number('12,345.6', '99G999D9');
 to_number 
-----------
   12345.6
(1 row)

Categories

Data type, String manipulation

See also

to_date(), to_timestamp(), to_char()