title: Determine Time Zone Offset in T-SQL
body: <p>My database application is going to be deployed at multiple sites in different time zones.</p>
  
  <p>I need a T-SQL function that will determine the UTC timestamp of midnight on January 1 of the current year for YTD calculations.  All of the data is stored in UTC timestamps.</p>
  
  <p>For example, Chicago is UTC-6 with Daylight Savings Time (DST), the function needs to return '2008-01-01 06:00:00' if run any time in 2008 in Chicago.  If run in New York (GMT-5 + DST) next year, it needs to return '2009-01-01 05:00:00'.</p>
  
  <p>I can get the current year from <code>YEAR(GETDATE())</code>.  I thought I could do a <code>DATEDIFF</code> between <code>GETDATE()</code> and <code>GETUTCDATE()</code> to determine the offset but the result depends on whether the query is run during DST or not.  I do not know of any built in T-SQL functions for determining the offset or whether or not the current time is DST or not?</p>
  
  <p>Does anyone have a solution to this problem in T-SQL?  I could hard code it or store it in a table but would prefer not to.  I suppose that this is a perfect situation for using CLR Integration in SQL Server 2005.  I am just wondering if there is a T-SQL solution that I am unaware of?</p>