GETDATE (Transact-SQL)

Returns the current database system timestamp as a datetime2(3) value. GETDATE() is a synonym for SYSDATETIME().

Syntax

GETDATE ( )

Applies to

SQL Server 2008 and later versions.

Description

GETDATE() returns the value of the system clock on the computer where SQL Server is running. This function returns a datetime2(3) value, which is the recommended data type for date and time values.

Example 1: Basic Usage

The following example returns the current date and time:

SELECT GETDATE();

Sample Output:

2023-10-27 10:30:45.123

Example 2: Using GETDATE in a WHERE Clause

Find all orders placed today:

SELECT order_id, order_date
FROM orders
WHERE CAST(order_date AS DATE) = CAST(GETDATE() AS DATE);

Note

GETDATE() is deterministic with respect to the time it is executed, but it is not deterministic across different executions. The value returned by GETDATE() can differ from the value returned by SYSDATETIME() if the session has overridden the current system time using SET DATEFIRST or other settings. However, GETDATE() always returns the current system timestamp.

Return Value

Returns the current database system timestamp as a datetime2(3) value.

See Also