Overview
The GETDATE() function returns the current server time stamp using the datetime format. This function returns the same value as the CURRENT_TIMESTAMP function. GETDATE() is used mostly in SQL Server, but CURRENT_TIMESTAMP is the ANSI SQL standard.
Explanation
Syntax
GETDATE()Parameters
- No parameters required
Simple GETDATE() Example
The following example will show the current server datetime.
SELECT GETDATE() as date
Difference between SQL GETDATE() and CURRENT_TIMESTAMP
The following example shows that there is no difference between the GETDATE() function and CURRENT_TIMESTAMP.
SELECT DATEDIFF(SECOND, GETDATE(), CURRENT_TIMESTAMP) as difference
How to use a Custom Format with GETDATE()
The following example will show GETDATE() in the dd-MM-yyyy hh:mm:ss tt format.
SELECT FORMAT(GETDATE(),'dd-MM-yy hh:mm:ss tt') as formatdate
How to use a Cultural Format with GETDATE
The following example will set the GETDATE() in a Spanish date format.
SELECT FORMAT(GETDATE(), 'dddd dd, MMMM, yyyy', 'ES-es') as spanish
Using SQL GETDATE() with Table Data
The following example will show the ProductIDs with a startdate between 7 and 8 years ago using GETDATE() as the current time.
SELECT Productid, DATEDIFF(YEAR, StartDate, GETDATE()) as years
FROM Production.ProductCostHistory
WHERE DATEDIFF(YEAR, StartDate, GETDATE()) BETWEEN 7 AND 8
Additional Information
- How to Get Current Date in SQL Server
- Mimic timestamp behavior of other database platforms to store last modified date
- SQL Convert Date to YYYYMMDD
- SQL CURRENT_TIMESTAMP

Daniel Calbimonte is a Microsoft Most Valuable Professional, Microsoft Certified Trainer and Microsoft Certified IT Professional for SQL Server. He is an accomplished SSIS author, teacher at IT Academies and has over 10 years of experience as a QE and developer for SQL Server related software. He has worked for the government, oil companies, web sites, magazines and universities around the world. Daniel also regularly speaks at SQL Servers conferences and blogs.
- MSSQLTips Awards: Author of the Year Contender – 2015-2018, 2022, 2023 | Champion (100+ tips) – 2018


