Aspdotnet-Suresh

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

Get Time Difference between Two Dates in SQL Server

Feb 12, 2014
Introduction:

In this article I will explain how to get time difference between two dates in
SQL server.
Description:
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


DECLARE @Sdate DATETIME, @Edate DATETIME, @Timediff VARCHAR(100)
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

Output:

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

Get the latest Asp.net, C#.net, 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

6 comments :

Sushil Gupta said...

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

Anonymous said...

sir, how to translate words English to Hindi.. like
http://transliteration.yahoo.com/hindi/
in asp.net / vb.net

Irtekaz Ahmed Khan said...

Thanks

Anonymous said...

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

SUDHANSHU SAXENA said...

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

Kumar Gaurav said...

Thanks.........

Give your Valuable Comments

Other Related Posts

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