Suppress decimal point like digits in to_char? - Mailing list pgsql-general

From Ken Tanzer
Subject Suppress decimal point like digits in to_char?
Date
Msg-id CAD3a31U8ZwsjcTxpM=ATtv2XLKO=id2kKQgDaOu9+51nBxsQig@mail.gmail.com
Whole thread Raw
Responses Re: Suppress decimal point like digits in to_char?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Hi.  Is there a way with to_char to suppress a decimal point, like a leading or trailing 0, so that integers will not have them, but non-ints will?  I'm hoping I'm missing something easy.  Thanks.

Ken

SELECT val,to_char(val::decimal(6,2),'FM999,999D99') FROM
( SELECT 1 AS val UNION SELECT 1.05 AS val) foo;

 val  | to_char 
------+---------
    1 | 1.
 1.05 | 1.05


--
AGENCY Software  
A Free Software data system
By and for non-profits
(253) 245-3801

learn more about AGENCY or
follow the discussion.

pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: Distributed Table Partitioning
Next
From: "David G. Johnston"
Date:
Subject: Re: Suppress decimal point like digits in to_char?