aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Get Time Difference between Two Dates in SQL Server

Feb 12, 2014

In this article I will explain how to get time difference between two dates in
SQL server.
In previous articles I explained SQL DATEDIFF Function to show date difference in days, difference between function and stored procedures, joins in SQL Server, substring function in SQL server and many articles relating to SQL server. Now I will explain how to get time difference between two dates in SQL server.

To get time difference between two dates in SQL server we need to write the query like this

SELECT @Sdate = '02/12/2014 08:40:18.000',@Edate='02/13/2014 09:52:48.000'
SET @Timediff=DATEDIFF(s, @Sdate, @Edate)
SELECT CONVERT(VARCHAR(5),@Timediff/3600)+':'+convert(varchar(5),@Timediff%3600/60)+':'+convert(varchar(5),@Timediff%60) AS TimeDiff
Once we run above query we will get output like as shown below


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Unknown said...

nice article..........

Anonymous said...

sir, how to translate words English to Hindi.. like
in /

Irtekaz Ahmed Khan said...


Anonymous said...

how to use in web forms FolderBrowserDialog?.. i want to store folder information in database, not a file information.. Ex. "C:\Data"

Unknown said...

really a great post................
Free Summer Training Companies

Unknown said...


Madhur Rastogi said...

Nice one....helpful...

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.