Re: Re: Format of the Money field - Mailing list pgsql-hackers

From Karel Zak
Subject Re: Re: Format of the Money field
Date
Msg-id Pine.LNX.3.96.1010205090114.22167A-100000@ara.zf.jcu.cz
Whole thread Raw
In response to Re: Re: Format of the Money field  (Dave Mertens <dave@redbull.zyprexia.com>)
List pgsql-hackers
On Sat, 3 Feb 2001, Dave Mertens wrote:

> On Sat, Feb 03, 2001 at 11:39:29AM -0500, Mitch Vincent wrote:
> > What's the standard on Money type (if there is one) and if it doesn't
> > include the $ (of course that would change based on what currency you were
> > using) then is it any different than numeric(9,2)? numeric(9,2) is what I
> > use for all fields that need to hold a dollar amount so I'm curious.. I
> > remember reading in the documentation that money was numeric(9,2) with the
> > dollar sign added but I wanted to check with the man :-)
This is possible if you use for formatting to_char()/to_number() with 
full locale support (here for example with de_DE locale):

test=# select to_char(1000.12, 'L9G999D99');  to_char
-------------DM 1.000,12
(1 row)

test=# select to_number('DM 1.000,12', 'L9G999D99');to_number
-----------  1000.12
(1 row)
IMHO use numeric and some formatting routine is good idea (better than
current money datetype..)

> Oh, never heard of currency?? NOT every country is using dollars. In a few
> months we in Europe are going to use the Euro. A money-type is normaly a
BTW, the other day I read nice paper about some US-banks that not known
Euro yet, and have problems with cheque in Euro... :-)
How locale is needful for Euro currency symbol? :-)

> floating type with a precision of 5 (float(5)). A money field is just like
A float for money? Not sure that it is normaly. See archive (already
discussed), here is a part or old Jan's letter:
    On Mon, 13 Dec 1999, Jan Wieck wrote:
    In  some  countries  (Germany  at least) storage of financial    booking information is not permitted to use
floats. And  you    aren't  allowed  to  use  it  for  calculation of taxes etc.,    instead you must use some datatype
witha fixable  number  of    digits after the decimal point.
 


> an float, only less precies. By the way, storing money values with an
> decimal precision is a (mostly) a bad thing. We Save currency amounts in
> the smallest unit. We save every amount in Eurocents. Our programs format 
> the amount to the proper format (US-format (35,673.56) or EuropeannFormat 
> (35.673,56). Currency signs are bad things in databases. Most database are
> international, so most amounts also!

In PostgreSQL it is output thing, a currency symbol is not inside DB. 
    Karel



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Like vs '=' bug with indexing
Next
From: "Maurizio"
Date:
Subject: Re: 7.1 beta 3 CHANGES FOR QNX