Using the SwitchOffset function for Time Zones

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 3

  • @Wilsonciprian_
    @Wilsonciprian_ 4 года назад

    the problem with AT TIME ZONE is that if you assign that result to a Variable or a Temp Table it will display the original time zone

  • @wilhelminasihene
    @wilhelminasihene 4 года назад

    T-SQL also supports a function called AT TIME ZONE that can be used instead of both the SWITCHOFFSET and the TODATETIMEOFFSET functions, and that uses named time zones instead of offsets.
    Example select GETDATE() AT TIME ZONE 'Central America Standard Time'
    Here is a list of time zones in SQL Server select * from sys.time_zone_info

    • @DatabasebyDoug
      @DatabasebyDoug  4 года назад

      Great suggestion! Note that this was added in SQL Server 2016 - see it here: docs.microsoft.com/en-us/sql/t-sql/queries/at-time-zone-transact-sql?view=sql-server-ver15