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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SUM of Time Duration

Author  Topic 

rn5a
Starting Member

25 Posts

Posted - 2008-10-13 : 07:43:39
A SQL Server DB table has a column named Duration whose datatype is varchar. Assume that 3 records under this column are (in hours & minutes) 25:30, 31:30, 16:00. The sum of these 3 records should give me 73:00 i.e. 73 hours & 00 minutes. How do I find the sum?

I could manage to get the hours using this query:

select sum(cast(substring(Duration, 0, charindex(':',Duration)) as int)) as hours from table1

Thanks,

Ron

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-13 : 07:44:40
Duplicate post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=112441



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -