Change the time zone offset of
the current date and time but unlike Switchoffset,
it wont change the time, just it change the offset value ie GMT it changes.
Lets take some example to understand this.
TODATETIMEOFFSET
( expression , time_zone )
Lets do some query to
understand this
select sysdatetimeoffset() as
Current_Time_With_OffsetValue
Current_Time_With_OffsetValue
----------------------------------
2013-12-19
17:32:48.2740254 +05:30
(1 row(s) affected)
So the current time with
offset is 2013-12-19 17:32:48.2740254
+05:30
Let’s apply TODATETIMEOFFSET
as well as SWITCHOFFSET to check what we will get
TODATETIMEOFFSET
select todatetimeoffset(sysdatetimeoffset(),'-04:00') as Changed_Time
Changed_Time
----------------------------------
2013-12-19 17:35:32.3950254 -04:00
SWITCHOFFSET
select switchoffset(sysdatetimeoffset(),'-04:00') as Changed_Time
Changed_Time
----------------------------------
2013-12-19 08:05:32.3950254 -04:00
Here we can see the with TODATETIMEOFFSET
only the offset (GMT) gets
changed to -04:00 where as in case of SWITCHOFFSET time and offset
(GMT) both gets changed.
Let’s take one few more
example
TODATETIMEOFFSET
select todatetimeoffset(sysdatetimeoffset(),'+12:00') as Changed_Time
Changed_Time
----------------------------------
2013-12-19 17:40:26.3130254 +12:00
SWITCHOFFSET
select switchoffset(sysdatetimeoffset(),'+12:00') as Changed_Time
Changed_Time
----------------------------------
2013-12-20 00:10:26.3130254 +12:00
Again we can see the with TODATETIMEOFFSET
only the offset (GMT) gets
changed to +12:00 where as in case of SWITCHOFFSET date, time
and offset (GMT) all gets changed.
NOTE: So with TODATETIMEOFFSET
you can change the offset only
without affecting your date and time where as in case of SWITCHOFFSET you can change date time and
offset according to the GMT passed as an argument to SWITCHOFFSET.
Every value code is an artist.
But to remain an artist revise required.
Post Reference: Vikram Aristocratic Elfin Share