Monday, 6 April 2015

How to add a timezone to datetimeoffset column

Sometimes developers forgot to give the appropriate datatype and the date timezone is simply truncated.

For instance,  you wanted to insert  the date 2015-04-06 17:37:03.106 +01:00 but at some point the type of the variable you stored the value was datetime as implicity conversion truncates de timezone

As shown in the following example


To fix this apply the function TODATETIMEOFFSET 

https://msdn.microsoft.com/en-us/library/bb630335.aspx

And the result is


You loose some precision but for my case it's just fine,


No comments:

Post a Comment