Received: from www.actarg.com (root@[209.180.91.25]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA14309 for ; Fri, 10 Sep 1999 11:55:51 -0400 (EDT) (envelope-from kyle@actarg.com) Received: from actarg.com (root@tao.actarg.com [192.168.1.1]) by www.actarg.com (8.8.7/8.8.7) with ESMTP id JAA05052; Fri, 10 Sep 1999 09:58:38 -0600 Received: from actarg.com (kyle@chi.actarg.com [192.168.2.16]) by actarg.com (8.8.7/8.8.7) with ESMTP id JAA20654; Fri, 10 Sep 1999 09:51:37 -0600 Sender: kyle@actarg.com Message-ID: <37D92B4D.125D0F59@actarg.com> Date: Fri, 10 Sep 1999 10:01:17 -0600 From: Kyle Bateman Organization: Action Target Inc X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.0.36 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@hub.org CC: secret@kearneydev.com Subject: Re: [SQL] Type Conversion: int4 -> Money Content-Type: multipart/mixed; boundary="------------3FA66A825364483B5864BCF5" This is a multi-part message in MIME format. --------------3FA66A825364483B5864BCF5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Herouth Maoz wrote: > 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 > > 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? I use this in tcl to format a dollar amount. Mine runs in the frontend, but it could easily be made into a pltcl function: #format for dollars, including commas #------------------------------------------ #val: the value as input by the user proc comma_dollar {val} { if {$val == {}} {set val 0.00} if {$val < 0} {set sign {-}; set val [expr -$val]} else {set sign {}} set val [format {%#.2f} $val] lassign [split $val .] dol cents set cdol {} for {set len [string length $dol]} {$len > 0} {incr len -3} { if {$cdol == {}} { set cdol "[string range $dol [expr $len - 3] [expr $len - 1]]" } else { set cdol "[string range $dol [expr $len - 3] [expr $len - 1]] $cdol } } return "$sign[join $cdol ,].$cents" } --------------3FA66A825364483B5864BCF5 Content-Type: text/x-vcard; charset=us-ascii; name="kyle.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Kyle Bateman Content-Disposition: attachment; filename="kyle.vcf" begin:vcard n:Bateman;Kyle tel;fax:801-377-8096 tel;work:801-377-8033x101 x-mozilla-html:FALSE url:www.actiontarget.com org:Action Target Inc adr:;;PO Box 636;Provo;UT;84603;US version:2.1 email;internet:kyle@actiontarget.com title:President x-mozilla-cpt:;-15520 fn:Kyle Bateman end:vcard --------------3FA66A825364483B5864BCF5--