August 3, 2016 at 4:16 pm
Our office has acquired a new application for Work Order Processing. On its database I see that it stores values of events in what I presume must be Universal Time, while these events are displayed in the software in the current local time. Since my location is California, I think that if I want to convert the stored event date time values into local date time values, I would need to subtract 8 hours, unless we are on Day Light Savings Time, in which case I would need to subtract only 7 hours. For example, one event on the database has the value of "2016-07-29 15:30:00.000" while the current local time value for the event was "2016-07-29 08:30:00.000".
Does anyone have any suggestions on how I could determine within SQL Server 2012 whether the current time frame is on Day Light Savings Time or not? I could then use either DATEADD (hour, -7, EventTime) or DATEADD (hour, -8, EventTime) to convert the Universal Time value into Pacific Time.
Alternatively, is there some SQL function that could do this conversion automatically that would take Day Light Savings time into account?
Thank you for your help.
August 3, 2016 at 6:53 pm
You need to have a table with DLS schedule, and use it when calculating current time.
You may get DSL schedules from various locations, for example from here:
http://wwp.greenwichmeantime.com/time-zone/rules/usa/
_____________
Code for TallyGenerator
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply