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 toSQL Server, asp.net, IIS, etc. Now I will explain how to get only time from datetime in SQL Server.
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 toSQL 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 |
No comments:
Post a Comment
Note: only a member of this blog may post a comment.