The Zen of Getdate() ...
-
Wednesday, January 09, 2013 9:40 PM
I read this on MSDN: "(GetDate) --- Returns the current database system timestamp as a datetime value without the database time zone offset.".
What does the "time zone offset" refer to? Whenever I use getdate() it returns the proper time for my location (i.e. GMT -8)
TIA,
edm2
All Replies
-
Wednesday, January 09, 2013 10:14 PMModerator
What is your SQL Server version?
See
select SYSDATETIME(), getdate(), GETUTCDATE()
and help for
GETDATE() returns your server's local time.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog- Edited by Naomi NMicrosoft Community Contributor, Moderator Wednesday, January 09, 2013 10:15 PM
-
Wednesday, January 09, 2013 10:28 PMSorry I forgot to mention it! Sql 2008
-
Wednesday, January 09, 2013 10:38 PMModerator
The offset is not filled automatically:
SELECT SYSDATETIME() AS SYSDATETIME; -- 2013-01-09 22:33:43.5390546 SELECT SYSDATETIMEOFFSET() AS SYSDATETIMEOFFSET; -- 2013-01-09 22:33:43.5390546 +00:00 SELECT SYSUTCDATETIME() AS SYSUTCDATETIME; -- 2013-01-09 22:33:43.5390546 SELECT CURRENT_TIMESTAMP AS [CURRENT_TIMESTAMP]; -- 2013-01-09 22:33:43.537 SELECT GETDATE() AS GETDATE; -- 2013-01-09 22:33:43.537 SELECT GETUTCDATE() AS GETUTCDATE; --2013-01-09 22:33:43.537
It can be set like:
BOL "DECLARE @datetimeoffset datetimeoffset(4) = '12-10-25 12:32:10.1234 +01:0';
DECLARE @time time(3) = @datetimeoffset;
SELECT @datetimeoffset AS '@datetimeoffset ', @time AS 'time';"http://msdn.microsoft.com/en-us/library/bb630289.aspx
Kalman Toth SQL 2008 GRAND SLAM
New Book: SQL Server 2012 Programming -
Wednesday, January 09, 2013 10:58 PM
What they are trying to say is that the value returned does not indicate in which time zone the value relates to. This is in difference to sysdatetimeoffset().
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se- Marked As Answer by edm2 Thursday, January 10, 2013 1:12 AM

