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 |
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-10-04 : 23:03:54
|
fromDate-->2011-03-06 13:05:00toDate-->2011-03-06 20:05:00 how can i count the hour and minute together?it should be 7 hour 0 minute |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
mani_1234
Starting Member
24 Posts |
Posted - 2012-10-05 : 00:57:57
|
create table #t ( fromdate datetime , todate datetime ) insert #t select '2011-03-06 13:05:00','2011-03-06 20:05:00 ' union all select '2011-03-06 13:05:00','2011-03-06 20:06:00 ' union all select '2011-03-06 13:05:00','2011-03-07 16:06:00 ' union all select '2011-03-06 09:00:00','2011-03-06 18:15:00 ' select * from #t select convert(varchar(5),datediff(HOUR ,fromdate,todate)) + ' hour '+ convert(Varchar(5),DATEDIFF (Minute,fromdate,todate)%60) +' Minute ' + convert(Varchar(5),DATEDIFF (SECOND ,fromdate,todate)%60) +' Second ' from #t |
|
|
|
|
|
|
|