datetime - Convert Historical Local Time to UTC Time in SQL Server -
i confronting sql server database contains many datetime values stored in local time. (yes, unfortunate!) have perhaps 5-10 years of data, means utc offset location change depending on time of year if region in question observes daylight savings time, , of course schedule on change occurred may change, example did in united states (where of these data originate) in 2007.
my objective convert these datetimes utc time @ sql level. short of loading entire olson or tz database , querying it, have technique converting historical local timestamp utc time? [if helps, conveniently, happen have latitude , longitude each row (could used identify timezone.]
note: row written in real time, trick of datediff(hour, getutcdate(), getdate()) utcoffset works fine, of course. problem applying retroactively dates occurred on either side of daylight savings time "barrier".
in following url can download funtions solve issue
http://sqlmag.com/t-sql/date-operations-made-easy
they develop function deal historical dates , convert them utc
regards
Comments
Post a Comment