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 |
|
rudba
Constraint Violating Yak Guru
415 Posts |
Posted - 2009-03-23 : 16:43:20
|
| i try to cast but get error, how to check null or overflow.normaly i have data on col0 and col1 like this:col0=2009-03-23 00:00:00.000col1=2009-03-23 23:59:59.999case when [col0] = 0 then 0 else cast(col1*3600/cast([col0] as decimal(10,2)) as decimal(10,2)) endMsg 8115, Level 16, State 2, Line 17Arithmetic overflow error converting expression to data type int.Warning: Null value is eliminated by an aggregate or other SET operation. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2009-03-23 : 17:11:29
|
| case when [col0] IS NULL THEN 0 WHEN [col0] = 0 then 0 else cast(col1*3600/cast([col0] as decimal(10,2)) as decimal(10,2)) endDinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2009-03-23 : 17:12:24
|
| and you could convert the 3600 to decimal Convert(decimal(10,2), 3600) as Tara said.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
rudba
Constraint Violating Yak Guru
415 Posts |
Posted - 2009-03-23 : 17:23:42
|
| thanks. |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-03-23 : 22:04:14
|
| I am afraid that your query makes no sense to me.You appear to be multiplying a datetime in col1 by 3600 and then dividing by a datetime in col2???What exactly are you trying to calculate?CODO ERGO SUM |
 |
|
|
|
|
|