experts, i would like to create a azure SQL DB with my local time, when i query select getdate() which need to return UTC+8 result. please provide me the guidance,
thanks.
experts, i would like to create a azure SQL DB with my local time, when i query select getdate() which need to return UTC+8 result. please provide me the guidance,
thanks.
The only chance to set timezone is on instance creation only.
https://docs.microsoft.com/en-us/azure/azure-sql/managed-instance/timezones-overview
And make sure you select "SQL managed instance" instead of "Azure SQL".

thanks for your URL, but it seen like that configuration GUI no longer valid in azure portal.
See my update on that, the screen capture is fresh on my portal screen. :)
thanks ! you make my day !
under database category have several SQL related , such like "SQL servers", "SQL managed instances" . my current setup just pick for the "SQL servers". not sure what different in between both.
anyway , this is really great ! finally i managed to see the GUI !
thanks !
Hi @MrYian-1536 ,
maybe these links are helpful:
https://techcommunity.microsoft.com/t5/azure-database-support-blog/lesson-learned-4-modifying-the-default-time-zone-for-your-local/ba-p/368798
https://docs.microsoft.com/en-us/azure/azure-sql/managed-instance/timezones-overview
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten
Hi AndreasBaumgarten,
thanks for your fast response, but it seen like "Set the time zone through the Azure portal" no longer valid. i cant find those settings from SQL instance setup nor SQL DB creation. and i do not think by keep convert getdate with function in order to retrieve UTC+8 is good idea.
thanks.
Use the function "AT TIME ZONE (Transact-SQL)" to convert UTC timestamp to your local time zone.
Hi Ola,
thanks for your fast response, it seen like this is SQL function to convert output data not from SQL itself.
it seen like UTC+0 is default and only setting for azure SQL DB
thanks.
This is really and Azure question, not a SQL Server question.
All AzureSQL instances are set to UTC and cannot be changed.
hi Tom.
thanks for your fast response. UTC+0 is AzureSQL default. but as user , i do not think which is make sense since the solution is around the world, AzureSQL cannot expect each time when we query the datetime then need to call function to +8 in order to point to my location.
anyway , thanks for your response.
I thought EntityFramework uses DateTimeOffset type to return datetime value by default (this type handles timezone difference), therefore is trivial to call .ToLocalTime() to get the time in local timezone.
Btw, Azure uses UTC with very good reason - to evade the problem with Daylight Saving Time, when for once every year, time goes backward and you have 2 time period with exactly the same timestamp, which is problematic to a lot of applications. When everything is stored in UTC at least it is a solvable problem.
Hi Cheong00,
but my code is within SP, then which need a convertor before i process the data, especially SP return result with datetime data.
thanks.
Again, it is not possible to change the time zone on AzureSQL. It is always going to be UTC time. It is not a "default", it is THE time zone and there is no way to change it.
It is very common to store all values in the database as UTC time and convert the time on the client side to the local time zone. You would be better off doing it that way when needed.
16 people are following this question.