Contents
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
- PostgreSQL 7.0
- added (commit b866d2e2)
Examples
Basic usage example for :
postgres=# SELECT to_number('12,345.6', '99G999D9'); to_number ----------- 12345.6 (1 row)
References
- PostgreSQL documentation: Formatting Functions
- PostgreSQL documentation: Template Patterns for Numeric Formatting