Using GETDATE

The GETDATE function produces the current date and time in SQL Server 2005 internal format for datetime values. GETDATE takes the null parameter ( ).

The following example finds the current system date and time:

SELECT GETDATE()

Here is the result set.

-------------------------
July 29 1995   2:50    PM

(1 row(s) affected)

You can use GETDATE in designing a report to have the current date and time printed every time the report is produced. GETDATE is also useful for functions such as logging the time a transaction occurred on an account.

You can use GETDATE anywhere to return the current system date. For example, you can use GETDATE as a default value for data entry, with a local variable, or comparing an order date to the current date.

See Also

Other Resources

GETDATE (Transact-SQL)
Date and Time Functions (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance