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

SQL Server - Get Time Part Only From DateTime Column in 2008 / 2005

Sep 3, 2013
Introduction:

Here I will explain how to get only time from datetime in SQL Server 2008 / 2005 or SQL Query to get only time part from datetime column or field in SQL Server 2008 or 2005.

Description:

In previous posts I explained get only date from datetime in SQL Server, Add row items as string with comma separated values, Exception handling in SQL Server with try catch, Add identity property to existing column in sql server, update multiple tables using inner join in SQL Server many articles relating to SQL Server, asp.net, IIS, etc. Now I will explain how to get only time from datetime in SQL Server.  

If we want to get only time from datetime column we need to write the query like as shown below


DECLARE @DateTime DATETIME
SELECT @DateTime = GETDATE()
SELECT CONVERT(VARCHAR(10),@DateTime ,108) AS Time
If we run above query we will get only time from datetime field like as shown below

Output

Time

07:29:14
I hope it helps you to get only time from required datetime fields. Happy Coding………

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

2 comments :

manoj kumar said...

very easy to understand thanks a lot

Anonymous said...

Thanks a lot

How we can Export data from gridview to Pdf,Excel, and word pls rply me.

Thanks in advance

Give your Valuable Comments

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

© 2015 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.