Tip of the Day : Generate Random Password User-Defined Function

SQL Server Helper - Tip of the Day

Similarities and Differences Between GETDATE and SYSDATETIME Date Functions

Prior to SQL Server 2008, there were only three functions that return the current system date and time of the computer on which the instance of SQL Server is running, namely CURRENT_TIMESTAMP, GETDATE and GETUTCDATE.  Beginning with SQLS erver 2008, three other date functions were introduced namely SYSDATETIME, SYSDATETIMEOFFSET and SYSUTCDATETIME.

The following article shows the similarities between the GETDATE() date function and the SYSDATETIME() date function.

Similarities

  • Returns the current date and time of the computer on which the instance of SQL Server is running.
  • The time zone offset is not included on both functions.
  • Both functions do not accept a parameter.
  • Both functions are nondeterministic functions. Views and expressions that reference these functions in a column cannot be indexed.

Differences

GETDATE()

SYSDATETIME()

Returns a DATETIME value

Returns a DATETIME2(7) value

Returns less fractional seconds precision, only 3 decimal places.

Returns more fractional seconds precision, up to 7 decimal places.

Accuracy is up to 0.00333 seconds.

Accuracy is up to 100 nanoseconds.

Available from SQL Server 2000 and onwards.

Available only from SQL Server 2008 and onwards.

Back to Tip of the Day List Next Tip