Is there any way to set the timeoffset
of a datetimeoffset
column directly without having to use SWITCHOFFSET
which changes the date as well?
In the post below, we can see the SWITCHOFFSET
will change the date accordingly along with setting the timeoffset (which is not what we want):
http://blog.sqlauthority.com/2010/07/15/sql-server-datetime-function-switchoffset-example/
For example I have the date value as '2013-02-10' and want to record it in different timezones, without losing the '2013-02-10'. Just set the timeoffset to what needed , e.g: +11, -4, -6, etc.
Is it possible?
Thanks.
Best Answer
To avoid the extra DateAdd (may be difficult if time zone is a variable), use: