SQL > SQL Date Functions > Getdate Function

The GETDATE function is used to retrieve the current database system time in SQL Server. A common use of GETDATE is to get today's date.

GETDATE() returns the current SQL Server database system date and time with no arguments required. It is most commonly used to timestamp rows during INSERT operations or as a DEFAULT column value.

Syntax

The syntax for the GETDATE function is,

GETDATE( )

GETDATE does not require any argument.

Example

The SQL statement,

SELECT GETDATE( );

produces the following result when run on March 15, 2000, at 00:05:02.123 AM.

'2000-03-15 00:05:02.123'

GETDATE function is most useful when we need to record the time a particular transaction happens. In SQL Server, we simply insert the value of the GETDATE( ) function into the table to achieve this. We can also set the default value of a column to be GETDATE( ) to achieve the same purpose.

The Oracle and MySQL equivalent of GETDATE is SYSDATE.

List of SQL Date Functions

Function NameDescription
 DATEADD  Adds an interval to a date value in SQL Server. 
 DATEDIFF  Calculates the difference between two dates in MySQL and SQL Server. 
 DATEPART  Extracts a specific part of a date/time value in SQL Server. 
 GETDATE  Retrieves database time in SQL Server. 
 SYSDATE  Retrieves database time in Oracle and MySQL. 
 EXTRACT  Retrieves a certain component of a date or timestamp value. 

Frequently Asked Questions

What does the SQL GETDATE function return?

GETDATE() returns the current database system date and time in SQL Server as a datetime value — including year, month, day, hours, minutes, seconds, and milliseconds (e.g., '2000-03-15 00:05:02.123').

Does GETDATE require any arguments?

No. GETDATE() takes no arguments. You call it simply as GETDATE() with empty parentheses.

What is the Oracle and MySQL equivalent of GETDATE?

In Oracle and MySQL, the equivalent function is SYSDATE, which also returns the current database system date and time.

How is GETDATE commonly used in practice?

GETDATE is commonly used to timestamp transactions — either by inserting GETDATE() as a column value during an INSERT statement, or by setting it as the DEFAULT value of a datetime column so rows are automatically timestamped on insertion.

Next: SQL SYSDATE

This page was last updated on March 19, 2026.




Copyright © 2026   1keydata.com   All Rights Reserved     Privacy Policy     About   Contact