Received: from nexus.kearneydev.com (IDENT:root@nexus.kearneydev.com [208.136.214.2]) by hub.org (8.9.3/8.9.3) with ESMTP id QAA97508 for ; Thu, 9 Sep 1999 16:03:41 -0400 (EDT) (envelope-from secret@kearneydev.com) Received: from kearneydev.com (atu.kearneydev.com [208.136.214.93]) by nexus.kearneydev.com (8.8.5/8.8.5) with ESMTP id QAA02588; Thu, 9 Sep 1999 16:03:19 -0400 Message-ID: <37D81287.ECD01CAC@kearneydev.com> Date: Thu, 09 Sep 1999 16:03:19 -0400 From: secret Organization: Kearney Development Co., Inc. X-Mailer: Mozilla 4.51 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Herouth Maoz CC: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Type Conversion: int4 -> Money References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Herouth Maoz wrote: > At 21:49 +0300 on 06/07/1999, secret wrote: > > > Is there a way to convert an int4 into a money? I have a few reports > > that require format of int4 as a money(I didn't use money for money > > because it's very difficult to convert money into other types it > > seems)... > > What language do you use for creating the report? Most of the time, you can > get the integer in the frontend (the report program), and format it using > some formatting routine. > > > The only way I can figure out how to do it is a kludge, such as: > > > > CREATE TABLE z(a int4, b money); > > > > Fill a with appropriate values, then set b as "1". SELECT a*b as a FROM > > z... And your done... But there should be some easier way to convert an > > int4 into a money rather than mulitply it? > > You can multiply it without creating a special table for it. For example, > here is a test table: > > testing=> select num, num * '1'::money from test1; > num|?column? > ------+----------- > 2|$2.00 > 4|$4.00 > -14|($14.00) > 38|$38.00 > 199|$199.00 > 100399|$100,399.00 > (6 rows) > > Is that what you wanted? > > Herouth > > -- > Herouth Maoz, Internet developer. > Open University of Israel - Telem project > http://telem.openu.ac.il/~herutma Perl... I ended up writing my own formatting function... It has one that does ####.## however not one that'll do the nice 123,456.33 ... :) Do you know if there are any public modules that do such things?