blueskybooking
asked on
SQL Registry Lookup : TZI Bias
The following outputted "Bias" does not appear to take into account Daylight Savings Time when executed on SQL 2008. The simplicity of the code is great, but it doesn't appear to get the current Bias. I changed the clock on my machine, restarted SQL Server, but I did not reboot my machine when I tested.
DECLARE @TZIBias int
EXECUTE master.dbo.xp_regread
'HKEY_LOCAL_MACHINE',
'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Pacific Standard Time',
'TZI',
@TZIBias OUTPUT
SELECT @TZIBias
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Was able to make it work with the following adjustments to the script.
StdOut.Write "Bias : " & mBias(strValue(0), strValue(1), strValue(2), strValue(3)) & vbCrLf
StdOut.Write "StandardBias : " & mBias(strValue(4), strValue(5), strValue(6), strValue(7)) & vbCrLf
StdOut.Write "DaylightBias : " & mBias(strValue(8), strValue(9), strValue(10), strValue(11)) & vbCrLf
...
Function mBias(intValue1, intValue2, intValue3, intValue4)
mBias = -(intValue1 + (256 * intValue2))
If intValue3 > 0 or intValue4 > 0 Then
mBias = mBias + 1 + (intValue3 + (256 * intValue4))
End If
End Function
To make things easier, I'd recommend that you use a VB.Net or C# CLR Storage Procedure. The link below is an example:
http://www.sqlmonster.com/Uwe/Forum.aspx/sql-server-programming/39935/SQL-Server-and-Time-Zome