Click here to Skip to main content
Click here to Skip to main content

Adding Time in HH:MM Format - Useful SQL Query

By , 7 Jun 2011
 
Hi,
Here is an alternative for your solution
 
SELECT CAST(DATEADD(MILLISECOND,
SUM(DATEDIFF(MILLISECOND,0,
CAST(TMP.TotalTime as DATETIME))),0) as TIME)
FROM
(
    SELECT CAST(timeduration AS TIME) TotalTime FROM mytable
) TMP

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Shahriar Iqbal Chowdhury/Galib
Technical Lead
Bangladesh Bangladesh
Member
I am a Software Engineer and Microsoft .NET technology enthusiast. Professionally I worked on several business domains and on diverse platforms. I love to learn and share new .net technology and my experience I gather in my engineering career. You can find me from here
 
Personal Site
Personal Blog
FB MS enthusiasts group
About Me

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralReason for my vote of 5 I gave this one a 5 as well. The cod...membercbragdon13 Jun '11 - 13:50 
GeneralTime datatype is specific to SQL SERVER 2008memberShahriar Iqbal Chowdhury8 Jun '11 - 0:48 
GeneralThis is fine but not working in MS Sql 2005; "Type time is n...memberJobless Creature7 Jun '11 - 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 7 Jun 2011
Article Copyright 2011 by Shahriar Iqbal Chowdhury/Galib
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid