By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,910 Members | 1,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,910 IT Pros & Developers. It's quick & easy.

Turn off "money" formatting?

P: n/a
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
Nov 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2

P: n/a
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


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3

P: n/a
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...ype-money.html

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

:-)
Karel

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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #4

P: n/a
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...ype-money.html

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

:-)
Karel

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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.