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 |
PatDeV
Posting Yak Master
197 Posts |
Posted - 2006-09-20 : 11:37:30
|
Hi all,how can i count hours between two timehelp plz!! |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-09-20 : 11:40:35
|
assuming the two times are datetime datatyps:select datediff(hour, datetimeCol1, datetimeCol2)Be One with the OptimizerTG |
 |
|
X002548
Not Just a Number
15586 Posts |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-09-20 : 11:44:40
|
>>SELECT @s = '10/24/1960'Is that your birthday, old man?Be One with the OptimizerTGEDIT: that's ok, if it is I'm still this many hour older than you: 13512 |
 |
|
PatDeV
Posting Yak Master
197 Posts |
Posted - 2006-09-20 : 13:59:39
|
but the time is in seconds????:( |
 |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-09-20 : 14:30:38
|
>>but the time is in seconds????:(huh?What is the datatype of your "time" values?Can you provide an example of what you have and what you want?You do know that you can convert seconds to hours by deviding by 3600.0, right?Be One with the OptimizerTG |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-21 : 02:32:47
|
Algebra 101.SELECT (ToSecondsColumn - FromSecondsColumn) / 3600.0 DiffInHoursFROM MyTablePeter LarssonHelsingborg, Sweden |
 |
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|