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?

Thanks heaps.


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.

Need Your Help

How do I test for an exception type in perl?

perl eval exception die

How can I check what kind of exception caused the script or eval block to terminate?

Lua: How to set a variable to zero

lua casting

I have variable that contains a number. While Lua allows variables to be set to nil, the variable then becomes toxic - destroying all code in its path.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.