Date/Time Functions – SWITCHOFFSET()

This is the last short articles or tidbits on Transaction SQL date/time functions.

It has surely been a-lot of work to write 41 articles on every way to slice and dice dates, times and offsets.

Today, I am going to talk about the SWTICHOFFSET() function. This function is useful when you want to convert time from one zone to another.

The function takes a date/time offset variable as input as well as the new offset value. It returns a date/time offset variable in the new zone.

The examples below convert the variable to one zone ahead three hours and one zone behind three hours.

The output from the test above is listed below.

In summary, the SWITCHOFFSET() function is useful when you have servers in different time zones and you want to know when something happened in relationship to your zone.

Related posts

Leave a Comment