November 9, 2011 at 8:37 am
Without any pre-populated tables, or external parameters passed is it possible to find out if the server is in daylight savings time?
November 9, 2011 at 9:27 am
if you know what offset your timezone is, you could calculate it;
for example in Miami Florida, i'm -5 from GMT , but when it's daylight savings, i'm -4;
by getting the diff between GetUTCDate and GetDate, you can see what it is currently...but you have to know what "normal" offset is.
select getdate(),getutcdate(),datediff(hh,getdate(),getutcdate())
--(No column name)(No column name)(No column name)
2011-11-09 11:24:54.9902011-11-09 16:24:54.9835
Lowell
November 11, 2011 at 10:25 am
The problem is that the DB server may be in one location while the clients could be spread throughout multiple time zones. So, I store the datetime data in UTC. It works fine until the the daylight saving time changes. Then all the scheduled notifications are off by one hour. If I knew it was DST or not then I could know whether to offset the time by an hour. Also the notifications are processed without any input from the client so I don't know what time zone they may be in. So, when a notification is scheduled the item is queued for delivery when the UTC time arrives not through some user client request.
November 11, 2011 at 10:31 am
if you have a datetime column for WHEN the data was actually entered, you could compare that to a TallyCalendar table(which you wanted to avoid) and get the DST offset.(ie if the data was entered on 7/23/2011, my TallyCalendar shows DST in hte US ranges:
select * from TallyCalendar where YearNumber=2011 and IsDaylightSavings=1
US DST Begins 2011-03-13 00:00:00.000
US DST Ends 2011-11-05 00:00:00.000
your application(web page?) could give you the users local time after at least one page submission,but that's all i can think of.
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply