Zeitwerte addieren

SET NOCOUNT ON
CREATE TABLE #temp_table 
( 
     hm VARCHAR(5)
)
INSERT #temp_table VALUES('8:30')
INSERT #temp_table VALUES('5:01')
INSERT #temp_table VALUES('12:59')
INSERT #temp_table VALUES('7:20')
SET NOCOUNT OFF
SELECT
     CONVERT(VARCHAR, SUM(DATEDIFF(ss, '1900-01-01 00:00', CONVERT(DATETIME, hm)))/3600) +
     ':' +
     CONVERT(VARCHAR, (SUM(DATEDIFF(ss, '1900-01-01 00:00', CONVERT(DATETIME, hm)))%3600)/60)
     
FROM
     #temp_table
DROP TABLE #temp_table

                                                              
------------------------------------------------------------- 
33:50

(1 row(s) affected)

Noch kein Feedback
Einen Kommentar hinterlassen

Ihre E-Mail-Adresse wird nicht auf dieser Seite angezeigt.
SchlechtExzellent
(Zeilenumbrüche werden zu <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)
Trackback-Adresse für diesen Eintrag

http://www.insidesql.org/blogs/htsrv/trackback.php?tb_id=1112