Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 decimal places on money values

Author  Topic 

obscuregirl
Starting Member

41 Posts

Posted - 2007-09-06 : 05:09:34
Hi

I have an SQL search that is converting two values to type money. I want it to show two digits after the decimal point but am getting inconsistent results. The first value is as follows:

tblInventoryItem.itemcost as originalcost (the column is datatype money)

This displays correctly i.e. 2000.00 or 150.70 etc

The second value is this:

tblInventoryItem.itemcost + tblUpgrades.ItemCost as totalcostincupgr (both columns are datatype money)

But this displays as 2000 or 150.7

How can I get the second value to show two decimal places even when the digits are zeros?

Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-06 : 05:32:07
Why? Why? Why?

Formatting is an issue for front-end (user) application, not database.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

obscuregirl
Starting Member

41 Posts

Posted - 2007-09-06 : 05:50:21
It's because I'm adding an enhancement to someone else's code and the way the code is written make's it easier to format the data coming from the database than it does to do it in the code. I know it's not the best way but it's just a lot quicker in this instance.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-06 : 05:54:43
CAST(<value or column name here> AS DECIMAL(15, 2))



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -