Get only time or only Date from a datetime string in SQL

If you have a datetime in string format or as varchar, than you can cast this string or varchar in datetime format.

And if you want to retrieve only date or only time from datetime than query is below.

CAST() method, you can use for conversation from any format to any other format in SQL


CAST(’01/14/2019′ AS DATETIME)

CAST(’01/14/2019′ AS TIME)

CAST(’01/14/2019′ AS DATE)