CHAPTER 2
Single-Table Queries
83
The first parses the input string by using a U.S. English culture, and the second by using a British
English culture.
The
SWITCHOFFSET
Function
The SWITCHOFFSET function adjusts an input DATETIMEOFFSET value to a specified time zone.
Syntax
SWITCHOFFSET(datetimeoffset_value, time_zone)
For example, the following code adjusts the current system datetimeoffset value to time zone
-05:00.
SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '-05:00');
So if the current system datetimeoffset value is February 12, 2009 10:00:00.0000000 -08:00, this
code returns the value February 12, 2009 13:00:00.0000000 -05:00.
The following code adjusts the current datetimeoffset value to UTC.
SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+00:00');
Assuming the aforementioned current datetimeoffset value, this code returns the value February
12, 2009 18:00:00.0000000 +00:00.
Do'stlaringiz bilan baham: |