What is the difference between CURRENT_TIMESTAMP
and GETDATE()
in SQL Server?
SELECT CURRENT_TIMESTAMP, GETDATE()
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() .
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.
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.
The CURRENT_TIMESTAMP function returns the current date and time, in a 'YYYY-MM-DD hh:mm:ss. mmm' format.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With