From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Gabriel Furstenheim Milerud <furstenheim(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Converting to number with given format |
Date: | 2018-09-19 12:57:07 |
Message-ID: | aa556ef6-2c98-1837-9799-7e0715268ba9@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 9/19/18 5:38 AM, Gabriel Furstenheim Milerud wrote:
> 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', '9V3')::int;
to_number
-----------
9
> SELECT to_number('9,000',another_format) =9000;
SELECT to_number('9,000', '99999');
to_number
-----------
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
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Jeremy Finzel | 2018-09-19 13:11:03 | postgres_fdw chooses remote index scan too rarely |
Previous Message | ncontu | 2018-09-19 12:40:13 | Re: Pgbouncer and postgres |