Re: Convert numeric to money

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: lucas(at)presserv(dot)org
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Convert numeric to money
Date: 2005-07-22 17:30:14
Message-ID: 20050722173014.GB29782@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Jul 22, 2005 at 11:03:40 -0300,
lucas(at)presserv(dot)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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tony Wasson 2005-07-22 18:11:09 Re: Multi-column returns from pgsql
Previous Message Jim Buttafuoco 2005-07-22 16:56:15 Re: Multi-column returns from pgsql