Tuesday, August 26, 2008

What timezone is MS SQL Server?

The simple answer is you have to calculate it. This can be done quite easily by using the following sql. This will actually give you offset from UTC (GMT), and not the user friendly name of the timezone. select DATEDIFF(hh, GetUtcDate(), GetDate())


Anonymous said...

Yes, of course! Thanks so much!

Paw said...

This does not account for daylight saving time.

Brent V said...

Hi Paw,

I guess it depends on what you mean "account for". For my purposes, I was using it to get the difference between UTC and server time. This does exactly that. That is the offset that I wanted. It did me little good to know the offset and then have to adjust it depending on the calendar of DST.

I'm not sure what your usage, is, but it works great depending on your goal I guess.

Anonymous said...

Note this doesn't take account of timezones that aren't whole hours from UTC, e.g. India.

Brent V said...


Good point. This is true, it doesn't take minutes into account. However, you can change the hh to a mm. This will give the difference in minutes. You can then divide by 60 to get the hours.

Vinu Felix said...

I dont know if this is what you meant..

DECLARE @value VARCHAR(100);
EXEC xp_regread "HKEY_LOCAL_MACHINE","System\CurrentControlSet\Control\TimeZoneInformation","StandardName",@value OUTPUT
SELECT @value;

gibsonherry said...

This blog is really helpful to pass on redesignd enlightening endeavors over web which is genuinely examination. I found one productive instance of this truth through this blog. Veeam Availability Suite for VMware