Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

UDF_GetGMTOffset

By Alex M,

Here is an example query that illustrates how to use the function to easily convert to and from UTC/GMT time and the SQL Server's local time.

SELECT GETDATE() AS 'Local Time',
GETUTCDATE() AS 'GMT Time',
DATEADD(HOUR, dbo.UDF_GetGMTOffset(), GETUTCDATE()) AS 'GMT Time to Local Time',
DATEADD(HOUR, dbo.UDF_GetGMTOffset() * -1, GETDATE()) AS 'Local Time to GMT Time',
dbo.UDF_GetGMTOffset() AS 'GMT Offset'
Results
Local Time GMT Time GMT Time to Local Time Local Time to GMT Time GMT Offset
2010-11-04 09:45:55.827 2010-11-04 14:45:55.827 2010-11-04 09:45:55.827 2010-11-04 14:45:55.827 -5

Total article views: 565 | Views in the last 30 days: 1
 
Related Articles
FORUM

UDF_GetGMTOffset

Comments posted to this topic are about the item [B]UDF_GetGMTOffset[/B] I see that you've defined @...

FORUM

Cube Localization

SSAS localization

FORUM

local server

no local server

FORUM

local replication

local replication error

FORUM

Processing Cubes Locally

Processing Cubes Locally

Tags
 
Contribute