SQL Server 101 – Get the Date part from DateTime

You can use the convert function in SQL Server to retrieve only the date part from the date time.

How to get the Date part from DateTime variable in SQL Server ?

Here’s a sample code snippet demonstrating how to do it.

SELECT CONVERT(DATE, GETDATE())

The GETDATE returns the current date along with the time and the convert function extracts only the DATE part of it.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this blog post, let’s learn about the error message “1459 – An error occurred while accessing the database mirroring...
In this blog post, let’s learn about the error message “7937 – Columnstore index has one or more missing column...