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
 General SQL Server Forums
 New to SQL Server Programming
 convert Integer to Time

Author  Topic 

eugz
Posting Yak Master

210 Posts

Posted - 2009-07-21 : 14:32:05
Hi All.
I have data type integer of columns Hours and Minutes. How to convert those ineger column to time and SUM those column?
Thanks

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-07-21 : 14:42:17
Something like this?

declare @table table (hours int, minutes int)

insert into @table
select 10,50 UNION ALL
select 8,25 UNION ALL
select 3,26 UNION ALL
select 4,52 UNION ALL
select 3,31

SELECT [Hours] = sum(t.hours)+ sum(t.minutes)/60,[minutes] = sum(t.minutes)%60

FROM @table t

Jim
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-21 : 14:42:43
SUM(60 * colHour + colMinute) AS TotalMinutes


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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-22 : 02:19:21
Also see
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=107275


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

- Advertisement -