Skip site navigation (1) Skip section navigation (2)

Re: What data type best used for money

From: "Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
To: <niccguard-dev(at)yahoo(dot)com>,<pgsql-novice(at)postgresql(dot)org>
Subject: Re: What data type best used for money
Date: 2007-10-31 23:25:58
Message-ID: 004201c81c15$645a4e70$9b0014ac@wbaus090 (view raw or flat)
Thread:
Lists: pgsql-novice
How accurate do you need to be?  Retail / POS level (ie, 2 decimal places)
or multi-currency with exchange rates etc (4+ decimal places)

 

Personally I use numeric and don't have any problems. Most of my fields only
need 2 decimals (RRP, wholesale prices etc), so I define them as
numeric(10,2) - I reckon I'm pretty safe to assume our company isn't going
to sell anything individually worth over $99,999,999.99

 

It actually helps identify problems when people make boo-boos - like
entering a 6 digit product code as the order quantity on a sales order!

 

Cheers,

~p

 

-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of
niccguard-dev(at)yahoo(dot)com
Sent: Thursday, 1 November 2007 06:34
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] What data type best used for money

 

Creating a database where monetary values will be stored and of course
retrieved with calculations.  What data types are best to use in this sort
of environment?

 

money is limited in quantity

numeric - documentation states "arithmetic on numeric values is very slow
compared to the integer types"

 

Just wanted to get some feedback on what seems to be the better way to go
and 'why'.

 

Thanks,

 

Aaron



THINK BEFORE YOU PRINT - Save paper if you don't really need to print this

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee.  If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments
e-mail.

In response to

pgsql-novice by date

Next:From: Jon SimeDate: 2007-11-01 00:16:01
Subject: Re: What data type best used for money
Previous:From: Tom LaneDate: 2007-10-31 21:43:01
Subject: Re: timestamp problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group