From: | Francisco Olarte <folarte(at)peoplecall(dot)com> |
---|---|
To: | Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Suppress decimal point like digits in to_char? |
Date: | 2016-03-14 18:46:18 |
Message-ID: | CA+bJJbzdmJTYNHJ22isGqwJWhDPN4esb9me4ddv3D3i3HQRTfA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Ken:
On Mon, Mar 14, 2016 at 7:33 PM, Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> wrote:
> Thanks for all the info and suggestions. I'll just observe that sure, you can do it with a regex, but I'm still surprised that this can't be done with to_char.
Well, this may be a good enhancement request, add something like
d=decimal point, supressed if alone.
> In particular, one might reasonably choose a format string like 'FM999,999D99' and not realize it will fail on whole numbers. Is there any particular reason the D is not suppressible in this case, either by default or as an option? It seems to me if the trailing 0s are suppressed, the decimal should follow suit for whole numbers.
It does not fail, it just works in a diffrent way of what you would
like. Regarding supression, IMO it's a bad thing, it can lead to
misleading results. Imagine it is, and you do a right aligned print (
usual for numbers ) of prices 5.45, 1.20, 99.00, 2.40, and you end up
with ( using x for align )
price:
------
xx5.45
xx1.20
xxxx99
xx2.40
It would be misleading, I prefer to have xxx99., ugly but clearer IMO
( of course one never supress decimals in prices, so I would use
990D00, but anyway ).
Francisco Olarte.
From | Date | Subject | |
---|---|---|---|
Next Message | Ken Tanzer | 2016-03-14 19:02:51 | Re: Suppress decimal point like digits in to_char? |
Previous Message | Ken Tanzer | 2016-03-14 18:33:53 | Re: Suppress decimal point like digits in to_char? |