question

Slick84 avatar image
Slick84 asked

getDate() & CURRENT_TIMESTAMP

Whats the difference between getDate() & CURRENT_TIMESTAMP?

I'm inserting records into an archival table and need to stamp each row with the current time. I have a column called "ArchiveDate" and I hard-code 'CURRENT_TIMESTAMP' in my INSERT statement. Is there a difference if I use getDate() ?

sql-server-2005t-sqldate-functionssystem-views
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered

CURRENT_TIMESTAMP is the ANSI standard method for getting date & time while GETDATE() is the T-SQL method. Also GETDATE() returns the datetime specific to the database including the database time zone offset where as CURRENT_TIMESTAMP doesn't include the database offset.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Aaron Alton avatar image
Aaron Alton answered

Great answer, Grant. This is an interesting link if you're looking at CURRENT_TIMESTAMP and GetDate()...

http://sqlblog.com/blogs/denis_gobo/archive/2009/02/22/12089.aspx

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.