2012年2月18日星期六

any good way to solve the daylight saving problem

i wanna show CST time in the report which are later than UTC time by 6 hours.SO we used dateADD(hh,-6,getUTSdate())

but the CST time will execute day light saving.

we r not sure where the server locates finally.

anyone kows some good ways to solve this issue?

Move the server to Arizona

{Just kidding }

|||

You could check the registry for the Keys:

ActiveTimeBias,

Bias

located at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation

|||

As Arnie said we need to fetch few data from the Registry.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones here you can find all the timezones and the corresponding offset(Standard & Daylight) values.

If your program written in .NET then its simple to call these objects (note: the regeistry hold few binary information which can deserilaized as objcet, it is responsible to convert the given UTC time to standard/daylight time). You have to use P/Invoke to call collect these infomarion.

|||

Take a look at this and see if it might address your problem:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=28712

|||

In 2005, you can use the CLR functions to deal with this. In a blog a while back (http://drsql.spaces.live.com/Blog/cns!80677FB08B3162E4!1311.entry) I posted a solution to the problem of UTC to server time. It is basically using the Date type in VB.NET to do the conversion. As I recall, you can also specify the time zone on the date type as well.

没有评论:

发表评论