In SQL Server 2000 only a new function introduced to get GMT
But, What about the earlier version of SQL Server 2000/Before SQL Server 2000 ?
Before SQL Server 2000
DECLARE @GMTTimeZone INT
EXEC MASTER.dbo.xp_regread
'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'ActiveTimeBias',
@GMTTimeZone OUT
SELECT DATEADD(MINUTE,@GMTTimeZone, GETDATE()) [ANCIENT METHOD]
GO
SQL Server 2000 onwards
SELECT GETUTCDATE() [GETUTCDATE()]
GO
Note: This method applies to all SQL Server versions
But, What about the earlier version of SQL Server 2000/Before SQL Server 2000 ?
Before SQL Server 2000
DECLARE @GMTTimeZone INT
EXEC MASTER.dbo.xp_regread
'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'ActiveTimeBias',
@GMTTimeZone OUT
SELECT DATEADD(MINUTE,@GMTTimeZone, GETDATE()) [ANCIENT METHOD]
GO
SQL Server 2000 onwards
SELECT GETUTCDATE() [GETUTCDATE()]
GO
Note: This method applies to all SQL Server versions
No comments:
Post a Comment