SQL Server GETDATE() Function: Get Current DateTime
In SQL Server, the
GETDATE() function returns the current date as a datetime value without the database time zone offset. This value is derived from the operating system of the computer on which the SQL Server is running.
GETDATE() returns the current date and time value of the system on which SQL Server is installed. It returns datetime type value.
Get Current Date & Time
In the following example, the
GETDATE() function is used in the SELECT statement to get the current timestamp of the computer running SQL Server.
SELECT GETDATE() AS CurrentDateTime
CONVERT() function with
GETDATE() to get only the date or time portion of the current date value.
SELECT CONVERT(DATE, GETDATE()) AS CurrentDate, CONVERT(DATE, GETDATE()) AS CurrentTime;