| Author |
Topic  |
|
|
macca
Posting Yak Master
Ireland
104 Posts |
Posted - 11/16/2007 : 10:51:27
|
I have a field in a database which is a datatype Money. When I run a select query the data is coming back with 4 decimal places like 100.0000 but I only want 2 decimal places like 100.00.
Anyone know how to get this? macca |
|
|
khtan
In (Som, Ni, Yak)
Singapore
13672 Posts |
Posted - 11/16/2007 : 11:00:18
|
1. don't use money data type. money is 4 decimal places 2. use convert() or cast() to convert to decimal data type with 2 decimal places.
KH Time is always against us
|
 |
|
|
macca
Posting Yak Master
Ireland
104 Posts |
Posted - 11/16/2007 : 11:10:16
|
how would you use CAsT or Convert to do this, can you give an example please.
Thanks, macca |
 |
|
|
jhocutt
Constraint Violating Yak Guru
USA
385 Posts |
Posted - 11/16/2007 : 11:12:34
|
create table #tmp ( c1 money )
insert into #tmp values (1.1234) select c1, cast(c1 as numeric(10,2)), convert(numeric(10,2), c1) from #tmp
"God does not play dice" -- Albert Einstein "Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
Edited by - jhocutt on 11/16/2007 11:13:41 |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
13672 Posts |
Posted - 11/16/2007 : 11:15:18
|
quote: Originally posted by macca
how would you use CAsT or Convert to do this, can you give an example please.
Thanks, macca
read the BOL
KH Time is always against us
|
 |
|
| |
Topic  |
|