GETDATE

GETDATE is a built-in function in SQL Server that returns the current datetime as a datetime datatype. It doesn't accept any parameters. The date and time are obtained from the operating system on which the SQL Server instance is running.

GETDATE()

Example

SELECT GETDATE() AS CurrentDateTime;

Output

---------------
CurrentDateTime
---------------
2022-10-10 18:40:12.123

Explanation

The GETDATE() function retrieves the current date and time from the SQL Server. The result is returned in ‘YYYY-MM-DD hh:mm:ss.mmm’ format. In the provided example, CurrentDateTime shows the current date and time at which the query was executed.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.