SQL GETDATE Function

Friday, December 16, 2011

tags SQL

The SQL GETDATE function is used to get the current date and time. This function is used when querying a Microsoft SQL Server. For MySQL Server, you can use the NOW function.

Syntax

GETDATE()


Example
SELECT GETDATE() as [Current Date and Time]


Results

Current Date and Time
2011-12-12 23:03:14.873

Aside from querying for the current date and time, you could use this function in the configuration of a table so that the current date and time is used when null values are passed. You can also use this function in an INSERT INTO statement as well. There are many differnt ways to use this function.

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

Head First SQL: Your Brain on SQL A Learners Guide SQL Cookbook