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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Round Function

Author  Topic 

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-12-13 : 11:26:32
I have the following number that is returned :

69.969999999999999

I want the number to be displayed as

69.97

Tried a couple different option with round(expresion,value) cant get much to work the way I want

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-13 : 11:33:19
select ROUND(69.969999999999999, 2)

doesn't work for you?



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-12-13 : 11:36:44
Nope, this is what im doing:

select ROUND(dbo.SECUMST2.PRICE,2) from SECUMST2 where SECUMST2.TICKER = 'ACLI'

The datatype for PRICE is float
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-13 : 12:58:16
so what's the problem?

give us some sample data.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-12-13 : 13:46:54
Here is one solution:

declare @price float
set @price = 69.969999999999999

select convert(numeric(7,2), @price)

output:
---------
69.97



Be One with the Optimizer
TG
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-12-13 : 14:16:27
FLOAT is poor choice of datatype for this kind of data. The internal binary format of the FLOAT datatype means that there is often no exact decimal equivalent for a number.

NUMERIC or MONEY is probably a better choice.










CODO ERGO SUM
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2006-12-13 : 15:23:45
casting the field as money fixed my issue, thanks for all your help
Go to Top of Page
   

- Advertisement -