Converting to number with given format

From: Gabriel Furstenheim Milerud <furstenheim(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Converting to number with given format
Date: 2018-09-19 12:38:06
Message-ID: CAJN3DWrePeKge2-e6NPTkHSpXfndCu7JdKBwALUpMkjKx7dm=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,
I'd like to convert a string number to a number being able to provide the
custom format.
With dates it works perfectly fine, so that I can do:

SELECT to_date('18 09 10', 'YY MM DD')

Is there something similar with numbers?

SELECT to_number('9,000', some_format) = 9;
SELECT to_number('9,000', another_format) = 9000;

It is not clear to me what some_format should be and what another_format
should be so that those selects are equal.

I've read the documentation but I can't find a similar example. In
stackoverflow they don't provide a solution either:
https://stackoverflow.com/questions/18882942/postgresql-convert-a-string-with-commas-into-an-integer

Thanks
Gabriel Fürstenheim

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ncontu 2018-09-19 12:40:13 Re: Pgbouncer and postgres
Previous Message Cédric Villemain 2018-09-19 07:44:06 Re: how to know whether query data from memory after pg_prewarm