Re: truncated numeric data

From: Andrew McMillan <Andrew(at)catalyst(dot)net(dot)nz>
To: Marc Zandvliet <marc(at)auroraworks(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: truncated numeric data
Date: 2001-01-30 19:20:25
Message-ID: 3A7713F9.9E9FE703@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Marc Zandvliet wrote:
>
> I've defined a field as numeric(5,2) - I'm using it for monetary amounts.
>
> After inserting values such as 8.50 or 29.00 into the database, a select
> from within psql gives the correct amount, i.e.
> -------
> 23.65
> 21.25
> 8.50
> 31.95
> 25.15
> 20.75
> 18.75
> 32.60
> 52.10
> 29.00
>
> However, windows based queries (through pgAdmin) drop trailing zeros, such
> as 8.5 or 29
>
> Can someone suggest how to prevent this from happening? Obviously I don't
> want to display prices without the decimals. Is it something to do with the
> odbc driver (Insight 6.5 & Postgresql 6.5)?

You can use to_char() to format the output - I forget the exact details
(I've only used it for date output), but there is a whole section
devoted to formatting with to_char() in the manual and it's a very
useful function.

Not sure if it was available at 6.5.? though - maybe 6.5.3. Definitely
in 7.0.x .

Cheers,
Andrew.
--
_____________________________________________________________________
Andrew McMillan, e-mail: Andrew(at)catalyst(dot)net(dot)nz
Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington
Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message rudy 2001-01-30 19:50:48 explain plan
Previous Message Andrew McMillan 2001-01-30 19:15:33 Re: Slow date comparison