?
Solved

Difference between GETDATE() and CURRENT_TIMESTAMP - SQL Server

Posted on 2011-09-26
4
Medium Priority
?
992 Views
Last Modified: 2012-05-12
Hi,

I know that CURRENT_TIMESTAMP is the ANSI SQL equivalent to GETDATE(). Other than this, can you please let me know what are the other differences between these two ?

Thanks
0
Comment
Question by:milani_lucie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 1500 total points
ID: 36600727
there is no difference both will give the same value when assigned / used.

to be ansi compatible and potentially more database independant use current_timestamp

but all database products (in general) use there own specific forms of date/time arithmetic  and functions so its not
much of a step
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 36600735
see also getutcdate()
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 36601039
use
SYSDATETIME and SYSUTCDATE have more fractional seconds precision than GETDATE and GETUTCDATE. SYSDATETIMEOFFSET includes the system time zone offset. SYSDATETIME, SYSUTCDATE, and SYSDATETIMEOFFSET can be assigned to a variable of any of the date and time types.

check out
SELECT SYSDATETIME()
    ,SYSDATETIMEOFFSET()
    ,SYSUTCDATETIME()
    ,CURRENT_TIMESTAMP
    ,GETDATE()
    ,GETUTCDATE();
/* Returned:
SYSDATETIME()      2007-04-30 13:10:02.0474381
SYSDATETIMEOFFSET()2007-04-30 13:10:02.0474381 -07:00
SYSUTCDATETIME()   2007-04-30 20:10:02.0474381
CURRENT_TIMESTAMP  2007-04-30 13:10:02.047
GETDATE()          2007-04-30 13:10:02.047
GETUTCDATE()       2007-04-30 20:10:02.047

from msdn http://msdn.microsoft.com/en-us/library/ms188751.aspx
0
 

Author Closing Comment

by:milani_lucie
ID: 36719578
I have mentioned this already.
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question