Get Time part from Datetime in MS SQL server

0
Our Reader Score
[Total: 0 Average: 0]
Overview: This article shows how to get only time part from DateTime in MS SQL Server  .i.e if the given date  value is  2015-03-02 09:32:15.000  and here you want to fetch only time part for this given date that is 09:32 time  as result will achieve by using given below query.

SQL QUERY:

Output :

Get Time part from Datetime in Ms Sqlserver
Get Time part from Datetime in Ms Sqlserver

Here we used datepart() function to get hours and minutes, and then cast as varchar so we concatenate it, as a result finally we get only time part from given date.

DATEPART() function is used to return a single part of a date/time, such as year, month, day, hour, minute, etc.


In Ms Sqlserver 2008 we get time part from DateTime by using query as follow

Output:

time part from datetime in ms sqlserver 2008
Time part from datetime in ms sqlserver 2008

Get your Printable Copy

NO COMMENTS

LEAVE A REPLY