But here we see how to get time part from datetime in MS SQL SERVER using simple query.
SQL QUERY:
//*
select GETDATE() as default_date,
cast(DATEPART(HOUR,GETDATE()) as varchar(2))+':'+ cast(DATEPART(MINUTE,GETDATE()) as varchar(4)) as time_part
//*
Output :
Get Time part from Datetime in MS SQL server
Here we used MS SQL 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 the time part from DateTime by using query as follow
//*
select GETDATE() default_date,
cast(GETDATE() as time) time_part
//*
Output:
Time part from DateTime in ms SQL server 2008
Hope you like this tutorial. If you have any recommendations, please let us know what you think in the comment section below! See you again next time!