Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between CURRENT_TIMESTAMP and GETDATE() [duplicate]

What is the difference between CURRENT_TIMESTAMP and GETDATE() in SQL Server?

SELECT CURRENT_TIMESTAMP, GETDATE() 
like image 490
mehdi lotfi Avatar asked Jun 15 '14 05:06

mehdi lotfi


People also ask

What is the difference between now () and CURRENT_TIMESTAMP?

NOW() returns a constant time that indicates the time at which the statement began to execute. NOW() returns the time at which the function or triggering statement began to execute, but SYSDATE() returns the exact time at which it executes. And CURRENT_TIMESTAMP , CURRENT_TIMESTAMP() are synonyms for NOW() .

What is the difference between Getdate and Sysdatetime?

The main difference between GETDATE() and SYSDATETIME() is that GETDATE returns the current date and time as DATETIME but SYSDATETIME returns a DATETIME2 value, which is more precise.

What is the difference between Getdate and Getutcdate?

The difference between GETDATE() and GETUTCDATE() is in time zone. The GETDATE() function return current date and time in the local time zone, the time zone where your database server is running, but GETUTCDATE() return current time and date in UTC (Universal Time Coordinate) or GMT time zone.

What does CURRENT_TIMESTAMP return in SQL?

The CURRENT_TIMESTAMP function returns the current date and time, in a 'YYYY-MM-DD hh:mm:ss. mmm' format.


1 Answers

CURRENT_TIMESTAMP is an ANSI SQL function whereas GETDATE is the T-SQL version of that same function.

One interesting thing to note however, is that CURRENT_TIMESTAMP is converted to GETDATE() when creating the object within SSMS. Both functions retrieve their value from the operating system in the same way. There is no difference between the two, performance wise.

CURRENT_TIMESTAMP is the recommended usage because it is portable to any ANSI compliant database, where as GETDATE() is not.

like image 183
Luke Peterson Avatar answered Sep 24 '22 07:09

Luke Peterson