How To Get Only The Date Part Of GetDate() In SQL Server?

Getting only the date part of GetDate() is very simple. GetDate() returns the current SQL Servers timestamp in datetime format. In my earlier article, I have explained how to get date from datetime variable. You can use the same technique here. On SQL Server 2008 or higher versions, you can use the CAST to date datatype to achieve this. Here is an example:

SELECT GetDate() AS 'Before Casting'
/* Result */
2019-06-20 10:38:01.197

SELECT CAST(GetDate() As date) AS 'With Casting'
GO
/* Result */
2019-06-20
Get Only The Date Part Of GetDate()

Reference


Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.