Addtion of time(in nvarchar format) using Sql server 2008

Posted by CGN007 under Sql Server category on | Points: 40 | Views : 1759
Create Script

CREATE TABLE [dbo].[timeadd](
[id] [int] NULL,
[time] [nvarchar](50) NULL

Insert Script
INSERT INTO [timeadd] VALUES(1,'11:50'),(2,'01:00'),(1,'09:30'),(1,'04:00')

SELECT	STUFF(CONVERT(CHAR(8), DATEADD(SECOND, theSeconds, '19000101'), 8), 1, 2, CAST(theSeconds / 3600 AS VARCHAR(12)))
SELECT ABS(SUM(DATEDIFF(SECOND, '00:00', time))) AS theSeconds
FROM timeadd
) AS t

Comments or Responses

Login to post response