0

Why there are different results (offset should be +03:00):

SELECT
    CURRENT_TIMEZONE() as [CURRENT_TIMEZONE()] , SYSDATETIMEOFFSET() as [SYSDATETIMEOFFSET()];

result is :

CURRENT_TIMEZONE()        SYSDATETIMEOFFSET()
(UTC+03:00) Istanbul      2022-01-20 10:32:03.6897159 +02:00

linux time is :

       Local time: Thu 2022-01-20 11:32:07 +03
  Universal time: Thu 2022-01-20 08:32:07 UTC
        RTC time: Thu 2022-01-20 08:32:07
       Time zone: Europe/Istanbul (+03, +0300)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
Thom A
  • 88,727
  • 11
  • 45
  • 75
  • 1
    As per the question guide, please do not post images of code, data, error messages, etc. - copy or type the text into the question. Please reserve the use of images for diagrams or demonstrating rendering bugs, things that are impossible to describe accurately via text. – Dale K Jan 20 '22 at 08:30
  • 1
    [From the docs:](https://learn.microsoft.com/en-us/sql/t-sql/functions/current-timezone-transact-sql?view=sql-server-ver15) *"For SQL Managed Instance, return value is based on the time zone of the instance itself assigned during instance creation, not the time zone of the underlying operating system."* – Charlieface Jan 20 '22 at 10:56
  • Thanks @Charlieface. where does time zone get During the creation of instance? Because during the creation time zone was same as now. And I also removed and reinstalled the instance, result is same. – Ali Rıza Arslan Jan 21 '22 at 08:57
  • Then I suggest you file a bug with Microsoft. `CURRENT_TIMEZONE` is a new function, there may be issues with it – Charlieface Jan 21 '22 at 09:07

1 Answers1

0

I realized SQL Server does not care Turkey adopted +03:00, does not use daylight saving and got a temporary solution. SQL Server does not work properly for Europe/Istanbul so I set Europe/Moscow same time zone with it.

  1. timedatectl set-timezone Europe/Moscow

  2. systemctl restart mssql-server

Problem is solved.

**CURRENT_TIMEZONE() SYSDATETIMEOFFSET()**
(UTC+03:00) Moscow, St. Petersburg 2022-02-02 17:39:04.6127420 +03:00
  • I have this problem at the moment with Asia/Tehran :( and there isn't any countries like us :)) https://stackoverflow.com/questions/75812412/sql-server-returning-wrong-timezone-info-for-iran-after-dst-stopped?noredirect=1#comment133748374_75812412 – mostafa8026 Mar 28 '23 at 17:25