Re: What data type best used for money - Mailing list pgsql-novice

From Phillip Smith
Subject Re: What data type best used for money
Date
Msg-id 004201c81c15$645a4e70$9b0014ac@wbaus090
Whole thread Raw
In response to What data type best used for money  (niccguard-dev@yahoo.com)
List 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@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of niccguard-dev@yahoo.com
Sent: Thursday, 1 November 2007 06:34
To: pgsql-novice@postgresql.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 e-mail.

*******************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

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: timestamp problem
Next
From: Jon Sime
Date:
Subject: Re: What data type best used for money