Thread: Turn off "money" formatting?

Turn off "money" formatting?

From
jerry.levan@eku.edu (Jerry)
Date:
Is it possible to turn off the "$" and "," that appear in "money" formatted
columns so I can dump the table in a numeric format?

The man page hints that lc_monetary controls the formatting but I
cannot find any clues on what to do...

Apparently money cannot be cast to anything.

I don't think it will be hard to write a custom tcl/perl
script that takes a "copy checks to...."  command to do the task
but I would like a cleaner solution....


Jerry

Re: Turn off "money" formatting?

From
Brendan Jurd
Date:
If you need to be able to cast money to numeric, you can just write your
own cast.  This is one of the things about postgres that I dearly love.

You could probably even write the cast function in SQL using regular
expressions.

Then, you just write a query with an explicit cast, e.g. SELECT foo ::
numeric FROM bar;

I noticed in the docs that the money type is actually deprecated, so you
probably want to consider converting your column to the numeric type
regardless.

BJ

Jerry wrote:

>Is it possible to turn off the "$" and "," that appear in "money" formatted
>columns so I can dump the table in a numeric format?
>
>The man page hints that lc_monetary controls the formatting but I
>cannot find any clues on what to do...
>
>Apparently money cannot be cast to anything.
>
>I don't think it will be hard to write a custom tcl/perl
>script that takes a "copy checks to...."  command to do the task
>but I would like a cleaner solution....
>
>
>Jerry
>
>---------------------------(end of broadcast)---------------------------
>TIP 8: explain analyze is your friend
>
>

Re: Turn off "money" formatting?

From
Karel Zak
Date:
On Sun, Jun 06, 2004 at 01:44:26PM -0700, Jerry wrote:
> Is it possible to turn off the "$" and "," that appear in "money" formatted
> columns so I can dump the table in a numeric format?

 Don't use  "money" datetype. You can  use other numerical  datetype and
 currency symbol add  to final result when you need  it. For example you
 can use "numeric" and to_char(.., '999L') for result formatting.

 I think  a lot of  things about "money"  you found in  PostgreSQL lists
 archives.

 .. and .. Please, read docs:

 http://developer.postgresql.org/docs/postgres/datatype-money.html

    Note:  The money type is deprecated. Use numeric or decimal
    instead, in combination with the to_char function.

 :-)


  Karel

--
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/