Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to extract two decimal places?

Status
Not open for further replies.

rpal

Programmer
Jun 16, 2003
37
US
Hello,

I have amount column with two 4 decimal places.

EX: 2275.4559 , I want get out put only 2275.46, how to do in SQL server, I am using Sql 2000.

Thanks.
 
You can use the ROUND function to round to any place, before of after the decimal point.

ROUND(2275.4559, 2)

This should give you what you need.
 
But It displaying results 2275.4600 I want to take out 00 and want to display only 2 decimal places.
 
Code:
CONVERT(VARCHAR,CAST(ROUND(2275.4559, 2) AS MONEY),1)
 
Sorry, I thought you were only trying to round. If you want to truncate you can use CAST as numeric.

select cast(round(1234.5678, 2) as numeric(15,2))

CAST() alone will sometimes also round, but I prefer to make sure it does what I expect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top