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 |
anupalavila
Yak Posting Veteran
56 Posts |
Posted - 2008-09-30 : 00:32:47
|
Hi Using this query SELECT DATEDIFF(hour,'2008-09-27 08:30:00.000','2008-09-27 13:00:02.000') we could get 5 as hour differenceIs there any query by which I can get the difference as 4:30:2Thanks and Regards Anu Palavila |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-30 : 00:45:28
|
[code]SELECT CAST(DATEDIFF(ss,'2008-09-27 08:30:00.000','2008-09-27 13:00:02.000')/3600 AS varchar(2)) + ':' +CAST((DATEDIFF(ss,'2008-09-27 08:30:00.000','2008-09-27 13:00:02.000')%3600)/60 AS varchar(2))+':'+CAST((DATEDIFF(ss,'2008-09-27 08:30:00.000','2008-09-27 13:00:02.000')%3600)%60AS varchar(2))[/code] |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-09-30 : 09:28:08
|
[code]select TimeDiff = convert(varchar(10),ET-ST,108)from ( -- Test Data select ST = convert(datetime,'2008-09-27 08:30:00.000'), ET = convert(datetime,'2008-09-27 13:00:02.000') ) aResults:TimeDiff ---------- 04:30:02(1 row(s) affected)[/code]CODO ERGO SUM |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|
|