pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedConvert numeric to money
4+ messages / 4 participants
[nested] [flat]
* Convert numeric to money
@ 2005-07-22 14:03 lucas@presserv.org
2005-07-22 17:30 ` Re: Convert numeric to money Bruno Wolff III <bruno@wolff.to>
2005-07-28 15:41 ` Re: Convert numeric to money codeWarrior <gpatnude@hotmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: lucas@presserv.org @ 2005-07-22 14:03 UTC (permalink / raw)
To: pgsql-sql
Hi.
I have searched in mailing-list archives about converting types, but I couldn't
found a function or clause that convert a numeric type to money type.
How Can I convert this types?
=> select '1234'::money;
money
------------
R$1.234,00
=> select '1234'::numeric::money;
ERROR: cannot cast type numeric to money
The problem is becouse I have a table with "numeric" field, and I need to show
it like "money" type (R$ 1.234,00). Is there a function to convert it??? Or is
there a function to mask the numeric field to show like money (with
R$x.xxx,xx)???
Thanks.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Convert numeric to money
2005-07-22 14:03 Convert numeric to money lucas@presserv.org
@ 2005-07-22 17:30 ` Bruno Wolff III <bruno@wolff.to>
2005-07-25 07:59 ` Re: Convert numeric to money Mauricio Fernandez <mfacontacto@ono.com>
1 sibling, 1 reply; 4+ messages in thread
From: Bruno Wolff III @ 2005-07-22 17:30 UTC (permalink / raw)
To: lucas@presserv.org; +Cc: pgsql-sql
On Fri, Jul 22, 2005 at 11:03:40 -0300,
lucas@presserv.org wrote:
> Hi.
> I have searched in mailing-list archives about converting types, but I couldn't
> found a function or clause that convert a numeric type to money type.
> How Can I convert this types?
>
> => select '1234'::money;
> money
> ------------
> R$1.234,00
>
> => select '1234'::numeric::money;
> ERROR: cannot cast type numeric to money
>
> The problem is becouse I have a table with "numeric" field, and I need to show
> it like "money" type (R$ 1.234,00). Is there a function to convert it??? Or is
> there a function to mask the numeric field to show like money (with
> R$x.xxx,xx)???
You probably want to use to_char to convert the numeric value to a string
which can be displayed.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Convert numeric to money
2005-07-22 14:03 Convert numeric to money lucas@presserv.org
2005-07-22 17:30 ` Re: Convert numeric to money Bruno Wolff III <bruno@wolff.to>
@ 2005-07-25 07:59 ` Mauricio Fernandez <mfacontacto@ono.com>
0 siblings, 0 replies; 4+ messages in thread
From: Mauricio Fernandez @ 2005-07-25 07:59 UTC (permalink / raw)
To: pgsql-sql
inspect your cast functions with:
create view showcasts as
select t.typname as source, t1.typname as target, p.proname as function,
(select case when c.castcontext = 'e'
then 'Must use Explicit Cast'
else ( select case when c.castcontext = 'i'
then 'Implicit cast for expressions and assignments'
else 'Implicit cast only for assignments'
end)
end ) as casttype
from pg_cast c, pg_type t, pg_type t1, pg_proc p
where c.castsource = t.oid and
c.casttarget = t1.oid and
c.castfunc = p.oid;
Un saludo.
Mauricio Fernandez A.
Ingeniero de Sistemas
Universidad Autonoma de Manizales
mfacontacto@ono.com
-----Mensaje original-----
De: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org]En nombre de Bruno Wolff III
Enviado el: viernes, 22 de julio de 2005 19:30
Para: lucas@presserv.org
CC: pgsql-sql@postgresql.org
Asunto: Re: [SQL] Convert numeric to money
On Fri, Jul 22, 2005 at 11:03:40 -0300,
lucas@presserv.org wrote:
> Hi.
> I have searched in mailing-list archives about converting types, but I
couldn't
> found a function or clause that convert a numeric type to money type.
> How Can I convert this types?
>
> => select '1234'::money;
> money
> ------------
> R$1.234,00
>
> => select '1234'::numeric::money;
> ERROR: cannot cast type numeric to money
>
> The problem is becouse I have a table with "numeric" field, and I need to
show
> it like "money" type (R$ 1.234,00). Is there a function to convert it???
Or is
> there a function to mask the numeric field to show like money (with
> R$x.xxx,xx)???
You probably want to use to_char to convert the numeric value to a string
which can be displayed.
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Convert numeric to money
2005-07-22 14:03 Convert numeric to money lucas@presserv.org
@ 2005-07-28 15:41 ` codeWarrior <gpatnude@hotmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: codeWarrior @ 2005-07-28 15:41 UTC (permalink / raw)
To: pgsql-sql
SELECT 1032::numeric(10,2);
<lucas@presserv.org> wrote in message
news:20050722110340.4ogyzmonnny800sc@www.presserv.org...
> Hi.
> I have searched in mailing-list archives about converting types, but I
> couldn't
> found a function or clause that convert a numeric type to money type.
> How Can I convert this types?
>
> => select '1234'::money;
> money
> ------------
> R$1.234,00
>
> => select '1234'::numeric::money;
> ERROR: cannot cast type numeric to money
>
> The problem is becouse I have a table with "numeric" field, and I need to
> show
> it like "money" type (R$ 1.234,00). Is there a function to convert it???
> Or is
> there a function to mask the numeric field to show like money (with
> R$x.xxx,xx)???
>
> Thanks.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-07-28 15:41 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-22 14:03 Convert numeric to money lucas@presserv.org
2005-07-22 17:30 ` Bruno Wolff III <bruno@wolff.to>
2005-07-25 07:59 ` Mauricio Fernandez <mfacontacto@ono.com>
2005-07-28 15:41 ` codeWarrior <gpatnude@hotmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox