Re: Suppress decimal point like digits in to_char?

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 19:26:02
Message-ID: CA+bJJbyY7NsmLBjqk7YM547TOp9nv6Xxj5+KVwo9d0U6981iBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

HI:

On Mon, Mar 14, 2016 at 8:02 PM, Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> wrote:
>> price:
>> ------
>> xx5.45
>> xx1.20
>> xxxx99
>> xx2.40
...
> I appreciate the comment and explanation. But your example shows numbers where the trailing 0s are not suppressed.

Yeah, my fault, but 5.45, 1.25, 99.00, 2.45 will create a that kind of
alignment which stronly suggest its .99. Of course it's not printed as
such, but visually it can trick you, that's why decimal points are
never supressed anc softwar has options to align coluns to the decimal
point.

> It seems to me that if you're requesting suppression of trailing 0s, then you're accepting that your numbers aren't going to align in the first place. And so it's hard for me to see how, for example "99." is ever going to be desirable output if suppression is what you're after.

Never desirable for me, but I never use d9, I always do d0, but you are right.

> And just as context on my end, the times I use to_char are generally to merge numbers into a document or some fragment of English text.

For the grouping ',' I see your point, I normally just use defaut
conversion for these as I dislike the grouping.

As I said, I could see a legitimitate case for Dd similar to the 09
stuff, but having so many replace options ( I think you can even do
<trim(trailing '.' from to_char(number, 'FM9999D99'))>, which is
easier on the eye but fails on locales, as the regexp does ( as a
note, in Spain they are inverted, dot for grouping comma for decimals
) ) I do not think it's a big deal, uglier things are coded by me
continuously nearly via muscle memory.

Francisco Olarte.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Devoy 2016-03-14 19:28:24 ON CONFLICT DO NOTHING RETURNING
Previous Message Ken Tanzer 2016-03-14 19:02:51 Re: Suppress decimal point like digits in to_char?