Sum Time Data Type Data with T-SQL


A sample for sum up minutes:


SELECT CAST(CAST(SUM(DATEDIFF(MINUTE, '0:00:00', DelayTime)) /60 AS VARCHAR(2))
            + ':'
            + CAST(SUM(DATEDIFF(MINUTE, '0:00:00', DelayTime)) %60 AS VARCHAR(2))
            + ':00' AS TIME(0)) as Delaytime, DATENAME(month,[date]) as CurrentMonth,Ename As Name
FROM   [dbo].[TbPassTime]
GROUP  BY DATENAME(month,[date]),Ename
--http://social.msdn.microsoft.com/Forums/en/transactsql/thread/2cd8d545-1c4f-4121-bd7b-50f598d18680

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s