remove $ from money field

Started by Robby Russellover 22 years ago4 messagesgeneral
Jump to latest
#1Robby Russell
rrussell@commandprompt.com

Should be a simple question.

When selecting a field that is of type money, how can I remove the $
when selected?

example: $10.00 would return as 10.00

-Robby

#2Arguile
arguile@lucentstudios.com
In reply to: Robby Russell (#1)
Re: remove $ from money field

On Fri, 2003-08-08 at 20:04, Robby Russell wrote:

Should be a simple question.

When selecting a field that is of type money, how can I remove the $
when selected?

example: $10.00 would return as 10.00

money as a datatype is deprecated, use numeric(9,2) instead (or whatever
precision you need).

Datatypes:
http://developer.postgresql.org/docs/postgres/datatype-money.html
http://developer.postgresql.org/docs/postgres/datatype.html#DATATYPE-NUMERIC-DECIMAL

Formatting:
http://developer.postgresql.org/docs/postgres/functions-formatting.html

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robby Russell (#1)
Re: remove $ from money field

Robby Russell <rrussell@commandprompt.com> writes:

When selecting a field that is of type money, how can I remove the $
when selected?

Actually, almost the only thing money does for you is put in the $ sign
;-). I'd recommend using type numeric instead, if you have any desire
for more flexibility.

regards, tom lane

#4Robert Treat
xzilla@users.sourceforge.net
In reply to: Robby Russell (#1)
Re: remove $ from money field

As others have said, money is deprecated. I used this function to
migrate some money data once; you could use it to reformat data if you
wanted.

CREATE OR REPLACE FUNCTION x_money(money) RETURNS decimal AS '

set moneydata $1

regsub -all {[,$]} $moneydata {} workable

return $workable

' language 'pltclu';

Robert Treat

On Fri, 2003-08-08 at 20:04, Robby Russell wrote:

Should be a simple question.

When selecting a field that is of type money, how can I remove the $
when selected?

example: $10.00 would return as 10.00

-Robby

--
PostgreSQL :: The Enterprise Open Source Database