Retrieving date in sql server, CURRENT_TIMESTAMP vs GetDate()

Sql ServerGetdate

Sql Server Problem Overview


Using SQL Server - which is the fastest or best practice method to use for date retrieval? Is there a difference?

Sql Server Solutions


Solution 1 - Sql Server

CURRENT_TIMESTAMP is standard ANSI SQL, and so is theoretically one tiny little island of 'don't need to change' amongst your thousands of SQL Server-specific lines of SQL if you ever need to move databases....

Solution 2 - Sql Server

CURRENT_TIMESTAMP is part of the ANSI SQL spec. GETDATE() is a SQL Server-specific function inherited from the original Sybase code on which SQL Server is based.

They do exactly the same thing, though.

Solution 3 - Sql Server

My vote is for CURRENT_TIMESTAMP for 'portability' reasons i.e. why be SQL Server -specific when there is a direct SQL-92 equivalent?

PS why was it not named getdatetime()? Now that SQL Server 2008 has a DATE and TIME data type, we can hope to get support for SQL-92's CURRENT_DATE and CURRENT_TIME, at which point getdate() could be potentially even more confusing.

Solution 4 - Sql Server

Books Online tells us that CURRENT_TIMESTAMP "is equivalent to GETDATE()".

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondigiguruView Question on Stackoverflow
Solution 1 - Sql ServerCowanView Answer on Stackoverflow
Solution 2 - Sql ServerDylan BeattieView Answer on Stackoverflow
Solution 3 - Sql ServeronedaywhenView Answer on Stackoverflow
Solution 4 - Sql ServerilaView Answer on Stackoverflow