Re: [GENERAL] Money

From: Bob Dusek <bobd(at)palaver(dot)net>
To: Bill Sneed <bsneed(at)mint(dot)net>
Cc: "pgsql-general(at)hub(dot)org" <pgsql-general(at)hub(dot)org>
Subject: Re: [GENERAL] Money
Date: 1998-12-13 22:31:54
Message-ID: Pine.LNX.3.96.981213172916.3290A-100000@farout.palaver.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey there,

I had some similar problems recently, try this

select someid, somemoneyfield * 2::float as product from table;

You cannot multiply money * money, apparently. But, money * float seems
to work fine. Same goes with division:

select someid, somemoneyfield / 2::float as quotient from table;

Hope this helps.

On Sat, 12 Dec 1998, Bill Sneed wrote:

> Date: Sat, 12 Dec 1998 22:09:19 +0000
> From: Bill Sneed <bsneed(at)mint(dot)net>
> To: "pgsql-general(at)hub(dot)org" <pgsql-general(at)hub(dot)org>
> Subject: [GENERAL] Money
>
> I' m trying to perform some simple arithmetic with a field datatype,
> money.
>
> For example, select part_id, cost from parts; gives the id and cost
> in dollars...
> select part_id, cost+1.00 from parts; ....adds $1.00 to
> displayed cost.
> select part_id, cost*2 from parts; produces an error message...
> "There is no operator '*' for types money.....retype this query using
> an explicit cast or.....define the operator using CREATE OPERATOR."
>
> If I examine the list of operators using \do, there are any number of
> them shown for *, money, int2, float4, etc.
>
> Question 1: Is this a list of existing oeprators or a list of
> permitted ones that I have to create?
>
> Question 2: I can't figure out haw to use the CAST :: ....Any
> hints?
>
> Again, TIA to one and all.
>
> .......Bill Sneed....Prospect, Maine......
>
>
>

In response to

  • Money at 1998-12-12 22:09:19 from Bill Sneed

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Clark Evans 1998-12-13 23:35:27 Re: [GENERAL] Introduction: Accounting/Bookeeping Project
Previous Message Anton de Wet 1998-12-13 14:33:55 Re: [GENERAL] Introduction: Accounting/Bookeeping Project