Tutorialsteacher

Follow Us

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.

Syntax:

GETDATE()

Parameters:

None.

Return Value

The 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.

Example: Get Current DateTime
SELECT GETDATE() AS CurrentDateTime

Use the CONVERT() function with GETDATE() to get only the date or time portion of the current date value.

Example: Get Current Date and Time
SELECT CONVERT(DATE, GETDATE()) AS CurrentDate, 
CONVERT(DATE, GETDATE()) AS CurrentTime;