If we run the following Query,
SELECT GETDATE() AS GTDATE
SELECT SYSDATETIME () as SYSDATE
We get same result but difference is GETDATE the precision is till miliseconds and of SYSDATETIME the precision is till nanoseconds.
In SQL Server 2005, We had only one function, GETDATE( ) which returns a DATETIME value. Its precision was till milliSeconds.
But later in SQL Server 2008, onwards, to get Time precision to Nano seconds, they introduced a new Data type called DATETIME2.
Getdate ( ) with returning DATETIME2 had a problem with precision with nanoseconds.
So SYSDATETIME is introduced which supports till NanoSeconds, which will return DATETIME2 Type and where as Getdate ( ) will return DATETIME type.
DATETIME value has precision upto 3 milliseconds.
DATETIME2 value has precision upto 100 Nanoseconds.
Comments
Post a Comment