I want to add my time zone with the function GETUTCDATE() in SQL Server. I searched several times, but did not found any relevant solution. Thanks in advance.
From SQL Server 2016 forward (and Azure SQL DB), you can do this:
SELECT SYSDATETIMEOFFSET() AT TIME ZONE @tz
where @tz is a valid Windows time zone identifier, such as 'Pacific Standard Time'
, 'Central European Standard Time'
, etc.
However, if you are on an older version of SQL Server, or prefer to use IANA time zone identifiers, you can use my SQL Server Time Zone Support project to do the following:
SELECT Tzdb.UtcToLocal(GETUTCDATE(), @tz)
where @tz
is an IANA standard time zone name, such as 'America/Los_Angeles'
or 'Europe/Budapest'
.