how do i get current system time stamp in SQL Server.
+2
A:
Since SQL Server 2000, we also had:
GETUTCDATE()
to get the UTC (Universal Time) - no dependant on local time zone settings
SQL Server 2008 (the OP didn't specify his exact version) also has:
SYSDATETIMEOFFSET()
to get the current local time including the timezone offset as DATETIMEOFFSET data type (new to SQL Server 2008)
SQL Server 2008 also offers SYSDATETIME()
and SYSDATETIMEUTC()
with more accuracy (down to 100ns) than GETDATE()
or GETUTCDATE()
in previous versions (accuracy: 3.33ms).
marc_s
2009-12-22 07:09:21
+2
A:
CURRENT_TIMESTAMP is ANSI compliant and equivalent to GETDATE()
Otherwise, you have a plethora of functions as mentioned in SQL Server 2008 BOL here (with link for SQL Server 2005 too).
I think marc_s might have missed 1 or 2 ;-)
gbn
2009-12-22 07:45:31
well, except for CURRENT_TIMESTAMP, I think I covered all the revelant ones, don't you agree? :-)
marc_s
2009-12-22 09:43:56