Re: Converting to number with given format

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: furstenheim(at)gmail(dot)com
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Converting to number with given format
Date: 2018-09-20 00:03:33
Message-ID: CAD3a31WSEFd2MUjznsPiK5REorJ_f_Dddw=iMfnVZP9-a2PvWA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 19, 2018 at 6:34 AM Gabriel Furstenheim Milerud <
furstenheim(at)gmail(dot)com> wrote:

Maybe that is not possible with numbers? To say in a format something like
> "my numbers have comma as decimal separator and no thousands separators" or
> "my numbers are point separated and have comma as thousands separator"
>
>
Would stripping out the thousand separator, and leaving in the decimal
separator work?

SELECT replace('9,000.34',',','')::numeric;
replace
---------
9000.34

If so, then (conceptually) does this work?

SELECT replace(

replace(my_numeric_string, user_thousand_sep, ''),

user_decimal_sep, system_decimal_sep

)::numeric

Or maybe I'm missing something about this!

Cheers,

Ken

--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message bricklen 2018-09-20 02:19:56 Re: Replicate Tables from SAP (DB2/HANA) to PostgreSQL
Previous Message Dylan Luong 2018-09-19 22:29:44 help with startup slave after pg_rewind