I’ll get straight to the point:
We had to change the timezone in which transactions were being logged from PST to UTC. However, we couldn’t yet fully convert over to UTC (it’s a lot of historical data to update). So, now we have a log table with logged events in PST up to a certain point in time, then after then everything is in UTC. I needed to modify existing ETL to dynamically shift all the UTC times to PST (full UTC conversion to come later). In short, this is how I did it (don’t scream too loudly – “it’s only temporary”
(assume ’4/20/2012 08:00′ is the time after which things are in UTC)
(All I did was get the hour offset between the getdate() and getutcdate() functions. Provided the system time is correct, timezone and all, this should do it)
select
(case when t.LogTime >= ’4/20/2012 08:00′ then dateadd(hh, datediff(hh,getdate(), getutcdate()), getdate()) else t.LogTime end) as LogTime
from MyFunDB.dbo.MyBigLog t (nolock)