How to Extract Only Date from Getdate in SQL Server

How to Extract Only Date from Getdate in SQL Server

Hi friends, in this post we will learn How to Extract Only Date from Getdate in SQL Server or you can say that How to return the date part only from a SQL Server datetime. Sometime we have requirement of only date part from our datetime datatype or getdate() function.

How to Extract Only Date from Getdate in SQL Server

Earlier we had discussed about: #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)AlwaysOn Availability Groups SQL ServerSQL Server Schema OwnershipDate and Time Data Type in SQL Server 2008 and Configure SSL Connections on Report Server-HTTPS

Query:

--DATE DIVIDED BY HYPHEN--
SELECT CONVERT(DATE, GETDATE())
GO
--DATE DIVIDED BY HYPHEN--
SELECT CAST(GETDATE() AS DATE)
GO
--DATE WITHOUT HYPHEN--
SELECT CONVERT(INT, CONVERT(VARCHAR(10), GETDATE(), 112))
GO