| Author |
Topic |
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2009-01-21 : 05:58:46
|
| Dear All,Have any one have idea how to remove off the decimal place?? My field type is Floateg:-1.30 = 1 ticket1.78 = 1 ticketI can't use round() or convert(integer,var) because this two will round out my figure. I want to completly to remove the decimal place doesn't care wat is the value after decimal place.Please Advise. Thank you.Regards,Michelle |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-21 : 06:01:11
|
| select left(13232.30 ,charindex('.',13232.30 ,1)-1) |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-21 : 06:03:37
|
| select cast(1.78 as int) |
 |
|
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2009-01-21 : 06:12:43
|
| Both above method are not working. select left(13232.30 ,charindex('.',13232.30 ,1)-1)Implicit conversion from data type money to varchar is not allowed. Use the CONVERT function to run this query.select cast(1.78 as int)return is 2. But i need the return is 1.Please adviseThank you. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-21 : 06:14:15
|
| wt is the datatype of colname this one also working fineselect left(13232.30 ,charindex('.',13232.30 ,1)-1)try this alsoselect floor(1342.83420) |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-21 : 06:15:00
|
quote: Originally posted by micnie_2020 Both above method are not working. select left(13232.30 ,charindex('.',13232.30 ,1)-1)Implicit conversion from data type money to varchar is not allowed. Use the CONVERT function to run this query.select cast(1.78 as int)return is 2. But i need the return is 1.Please adviseThank you.
select cast(1.78 as int) output: 1 check it once. |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-21 : 06:17:09
|
| Ok, Welcome |
 |
|
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2009-01-21 : 06:20:56
|
| Thank you bklrIs working fine with Floor. Thank you very much.Regards,Michelle |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-21 : 06:24:39
|
quote: Originally posted by micnie_2020 Thank you bklrIs working fine with Floor. Thank you very much.Regards,Michelle
ur welcome but check this once select left(13232.30 ,charindex('.',13232.30 ,1)-1)it is working fine |
 |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-21 : 06:27:47
|
quote: Originally posted by micnie_2020 Dear All,Have any one have idea how to remove off the decimal place?? My field type is Floateg:-1.30 = 1 ticket1.78 = 1 ticketI can't use round() or convert(integer,var) because this two will round out my figure. I want to completly to remove the decimal place doesn't care wat is the value after decimal place.Please Advise. Thank you.Regards,Michelle
convert works for youselect convert(int,1.1324)o/p is 1Jai Krishna |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2009-01-21 : 07:01:05
|
I'd say floor is better style since the intention is obvious, but cast and floor behave differently:declare @f floatset @f = -1.78select floor(@f), cast(@f as int) |
 |
|
|
|