pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: function to format floats as money? (removing space padding)
2+ messages / 2 participants
[nested] [flat]
* Re: function to format floats as money? (removing space padding)
@ 2001-04-19 19:53 Mark Stosberg <mark@summersault.com>
2001-04-20 07:54 ` Re: function to format floats as money? (removing space padding) Karel Zak <zakkr@zf.jcu.cz>
0 siblings, 1 reply; 2+ messages in thread
From: Mark Stosberg @ 2001-04-19 19:53 UTC (permalink / raw)
To: pgsql-sql
Now that I've figured out that numeric is good for storing money, and
that I can format with like this:
to_char(price, '9,999,999.99') as price
Then I discovered that sometimes this returns leading spaces I don't
want. I can get rid of them like this:
trim(to_char(price, '9,999,999.99')) as price
Is that the recommended money formatting style, for amounts less than
9,999,999.99? (assuming I'll tack on my own currency symbol? ). Other
there other general styles that folks like for this? Thanks,
-mark
personal website } Summersault Website Development
http://mark.stosberg.com/ { http://www.summersault.com/
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: function to format floats as money? (removing space padding)
2001-04-19 19:53 Re: function to format floats as money? (removing space padding) Mark Stosberg <mark@summersault.com>
@ 2001-04-20 07:54 ` Karel Zak <zakkr@zf.jcu.cz>
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2001-04-20 07:54 UTC (permalink / raw)
To: Mark Stosberg <mark@summersault.com>; +Cc: pgsql-sql
On Thu, Apr 19, 2001 at 02:53:38PM -0500, Mark Stosberg wrote:
>
> Now that I've figured out that numeric is good for storing money, and
> that I can format with like this:
>
> to_char(price, '9,999,999.99') as price
>
> Then I discovered that sometimes this returns leading spaces I don't
> want. I can get rid of them like this:
>
> trim(to_char(price, '9,999,999.99')) as price
>
> Is that the recommended money formatting style, for amounts less than
> 9,999,999.99? (assuming I'll tack on my own currency symbol? ). Other
> there other general styles that folks like for this? Thanks,
May be try docs, what? :-)
test=# select to_char(123456, '9,999,999.99');
to_char
---------------
123,456.00
(1 row)
test=# select to_char(123456, 'FM9,999,999.99');
to_char
---------
123,456
(1 row)
test=# select to_char(123456, 'FM9,999,999.00');
to_char
------------
123,456.00
(1 row)
test=# select to_char(123, 'FM0,999,999.00');
to_char
--------------
0,000,123.00
(1 row)
test=# select to_char(123456, 'LFM9,999,999.00');
to_char
------------
$123,456.00
(1 row)
FM ....fill mode, skip blank spaces and zeroes (if not set '0' instead '9')
L ....currency symbol (from actual locales)
Right?
Karel
--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/
C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-04-20 07:54 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-19 19:53 Re: function to format floats as money? (removing space padding) Mark Stosberg <mark@summersault.com>
2001-04-20 07:54 ` Karel Zak <zakkr@zf.jcu.cz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox