TSQL Converting DateOffset to UTC
I'm trying to convert the datetimeOffset stored in SQL Azure to UTC DateTime so that I can perform a proper calculation.
The DateTimeOffset is stored as local NewZealand Time as:
2011-05-31 21:40:00.0000000 +10:00
I need to convert the above values to UTC so that I can perform date time calculation. Is there any way to achieve this using TSQL and Azure SSRS?
Here's another thread that may give you some ideas: TSQL: How to convert local time to UTC? (SQLServer2008)
Off the top of my head, if you know the datetime you are working with is from New Zealand, you know what the UTC offset is. It should be based on one of two values (if they have daylight savings).
So do a dateadd with a function call that determines if you are in daylight savings or not. How do you determine if you are in daylight savings for a given date? Good question. Unless there is a .NET function you could turn into a CLR function, I would just create a look up table and a function that tests against that. The function either returns a boolean or the proper offset for New Zealand.
I would save the new derived value into a new column, but I'm not sure what your needs are.