Showing posts with label SQL Server 2000. Show all posts
Showing posts with label SQL Server 2000. Show all posts

How to get GMT (Greenwich Mean Time) rather than current time in earlier version of SQL Server ?

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