Money data type and two decimal places

Posts   
 
    
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 30-Nov-2006 22:54:33   

I'm having a problem in our application where I save a monetary value and want to result to have two decimal places. The money data type always uses four so I'm thinking of using something like a decimal (18,2). Does anyone have any suggestions?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 01-Dec-2006 08:10:04   

Are you speaking from the Database design point of view?

I think decimal(18, 2) will do, the only difference is that it's 1 byte more in storage than the money data type.

decimal (18, 2) = 9 bytes money = 8 bytes

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 01-Dec-2006 10:40:54   

Which DB type are you using? Though I think a decimal will do better in this case. I think money uses 4 decimals on some db's to overcome rounding issues in signicant digits.

Frans Bouma | Lead developer LLBLGen Pro
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 01-Dec-2006 18:30:18   

Maybe I'm asking if there is anyway to make a custom money type uses only two decimal places instead of four. I think I'll probably end up using the decimal (18,2) for this as the size I'm not concerned with right now.

Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 02-Dec-2006 23:46:16   

Some DB's support custom data types, which are useful in exactly your scenario. You could create a custom data type in SQL Server called "currency" (not sure if that's a reserved word) as decimal(18,2). Then your columns would be of type "currency" and you could later change the custom data type if necessary.

wiredeye
User
Posts: 18
Joined: 15-Jul-2008
# Posted on: 26-Sep-2008 16:34:22   

I store a value on SQL Server 2005 as decimal(12,2). The number returned to me is a single and has a 3rd decimal changing "xxx.37" to "xxx.375". Can you point me to the area of LLBLGen Pro where I can stop that behavior? It causes issues with rounding.

Using Self-servicing 2.5

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Sep-2008 14:48:53   

A decimal type in sqlserver is mapped as a decimal in .NET, so I don't really see how this can be a 'single'. Do you use a type converter?

Also, next time please open a new thread instead of hijacking an old thread, thanks

Frans Bouma | Lead developer LLBLGen Pro