Click here to Skip to main content
16,018,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I Have a Hours column with data type NUMERIC(5,2) and values are Like: 01.25, 02.30, 05.56, 00.50

Now I Want To SUM of This Total Hours and Minutes Like Answer is : 10.41 using sql server

Can anybody plz help me ?
Posted
Updated 21-Nov-13 0:06am
v3

See this Stack Overflow's question: "How To sum up time field in sql server"[^].
 
Share this answer
 
This is another alternative.

SQL
select convert(varchar(3),SUM(s)/60) + ':' +  convert(varchar(3),SUM(s)%60)
from(
select convert(int,substring('01:25',1,2))*60 + convert(int,substring('01:25',4,2)) s
union all
select convert(int,substring('01:25',1,2))*60 + convert(int,substring('01:25',4,2)) s

) p
 
Share this answer
 
SQL
DECLARE @Minute1 INT
SET @Minute1 = ( SELECT DATEDIFF(MINUTE,GETDATE(),GETDATE()))
SELECT CAST( @Minute1/60 AS VARCHAR(5))+ ' Hrs' + ':'+ RIGHT('0' + CAST( @Minute1%60 AS VARCHAR(2)), 2)+' Min' AS 'WorkingTime'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900