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.
Author |
Topic |
chippyles
Yak Posting Veteran
68 Posts |
Posted - 2006-08-04 : 10:49:00
|
I have a column named nRUN_TIME that is a smallint. the numbers in this colum are minutes a product ran. so on an average it is anywhere between 84 and 130 minutes. I need to divide this number by 1440 to give me the fraction of a day. for example, I have one record at 136 minutes and I need the results to be 0.094 after I divide it by 1440. If I do this in SQL the number comes out to 0. I tried to convert nRUN_TIME to a decimal and a numeric, but it either gives me errors or I still get a 0. What can I do in this situation?Thanks!! |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-08-04 : 10:52:07
|
[code]declare @nRUN_TIME smallintselect @nRUN_TIME = 136select @nRUN_TIME / 1440 -- 0select @nRUN_TIME * 1.0 / 1440 -- 0.094444select convert(decimal(10,3), @nRUN_TIME * 1.0 / 1440) -- 0.094[/code] KH |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-04 : 10:52:08
|
U may use either of the following (and many more ways) 1.0 * nRUN_TIME/1440 convert(decimal(10,2),nRUN_TIME)/1440Srinika |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-08-04 : 10:53:01
|
KH |
|
|
chippyles
Yak Posting Veteran
68 Posts |
Posted - 2006-08-04 : 11:11:33
|
thanks!! |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-04 : 11:22:47
|
quote: Originally posted by khtan KH
One Second Srinika |
|
|
|
|
|