In this post i would like to discuss with you about displaying current date and time in SQL Server.
CURRENT_TIMESTAMP is ANSI compliant. This value is based on the operating system where the SQL Server instance is running. This function is nondeterministic function.
GETDATE() is inherited from sybase.
SYSDATETIME(), this value is based on the operating system where the SQL Server instance is running. This function is nondeterministic function. The return type of this function is datetime2. So this is more accurate than any other time based function.
In addition to this there is another way to display the current date and time.
The {fn Now()} is an ODBC canonical function which can be used in T-SQL. There is no performance difference between any of these functions.
SELECT SYSDATETIME() AS "SYSDATETIME",
CURRENT_TIMESTAMP AS "CURRENT_TIMESTAMP",
GETDATE() AS "GETDATE",
{fn NOW()} AS "fn_now()"
Thursday, January 14, 2010
Get Current date and time in SQL Server using CURRENT_TIMESTAMP, GETDATE(), SYSDATETIME()
Labels:
DotNetVJ,
SQL Server,
Vijaya Kadiyala
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment