GETDATE()

Returns the current database system timestamp as a datetime value.

Syntax

GETDATE ( )

Description

GETDATE() returns the current date and time of the server on which SQL Server is running. This value is a datetime data type. It reflects the time when the function is executed within the current session.

Return Value

Returns the current system date and time.

Data Type: datetime

Examples

1. Get the current date and time

SELECT GETDATE();

This will return a result similar to:

2023-10-27 10:30:55.123

2. Insert the current date and time into a table

Assuming you have a table named Orders with a column OrderDate of type datetime:

INSERT INTO Orders (OrderDate, CustomerID) VALUES (GETDATE(), 101);

Remarks

See Also