Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving date in sql server, CURRENT_TIMESTAMP vs GetDate()

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

like image 895
digiguru Avatar asked Oct 09 '08 09:10

digiguru


People also ask

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 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 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.


1 Answers

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....

like image 80
Cowan Avatar answered Sep 18 '22 18:09

Cowan