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
 delete extra digits

Author  Topic 

a.ashabi
Posting Yak Master

117 Posts

Posted - 2009-07-06 : 18:05:12
Hi.I'd like to get rid of the last 2 digits on my money field.
which means if the values are :
123.456
5.56
45.4569
12.2

I need these results:
12.45
5.56
45.45
12.2

plz help thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-06 : 18:16:28
round(col, 2)

or

convert(decimal(10,2), col)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2009-07-06 : 18:27:22
thank u so much :)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-07 : 02:15:39
select data,round(data,2),convert(decimal(10,2), data),cast(cast(data*100 as int)/100.0 as decimal(12,2)) from
(
select cast('123.456' as decimal(12,3) )as data union all
select '5.56' union all
select '45.4569' union all
select '12.2'
)m


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -