|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 05, 2013 10:39 AM
Points: 16,
Visits: 26
|
|
Hi,
Here minibgtime and maxendtime are in below format 2013-02-19 16:15:48.000
select datediff (Mi,Cast((minibgtime) as datetime), Cast((maxendtime) as datetime))/60) as Total_Minutes from tablename
Now i am getting something like a number 150 minutes but i want to see that as 2:30:00
as 150 mins = two hrs 30 minutes.
Any help is appreciated.
Thanks, Sam.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 11:56 AM
Points: 1,315,
Visits: 2,885
|
|
add those minutes to a date @ 00:00:00 hrs then format as a time. As an example:
declare @mins int set @mins = 150
select convert(char(5),dateadd(minute,@mins,'01/01/2013'),108)
The probability of survival is inversely proportional to the angle of arrival.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 05, 2013 10:39 AM
Points: 16,
Visits: 26
|
|
select datediff (Mi,Cast((minibgtime) as datetime), Cast((maxendtime) as datetime))/60) as Total_Minutes from tablename
The above Sql Query should give me 2:30:00 instead of 150 minutes, here i have make changes in the above query , just to clarify i have to make changes inthe above query itself.
Thankyou.
-- Sam.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 05, 2013 10:39 AM
Points: 16,
Visits: 26
|
|
Never Mind i figured out select (CONVERT(varchar(6), DATEDIFF(second, minibgtime, maxendtime)/3600) + ':' + RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, minibgtime, maxendtime) % 3600) / 60), 2) + ':' + RIGHT('0' + CONVERT(varchar(2), DATEDIFF(second, minibgtime, maxendtime) % 60), 2)) as Total_Time
from tablename
Thankyou.
-- Sam.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 6:50 AM
Points: 2,221,
Visits: 4,183
|
|
|
|
|