Lesson Learned #4: Modifying the default time zone for your local time zone.
Published Mar 14 2019 01:13 AM 54.6K Views
First published on MSDN on Jul 27, 2016


Currently, the default time zone on Azure SQL DB is UTC . Unfortunately, there is not possible to change by server configuration or database configuration.

All Azure services use UTC time zone settings, regardless of their physical location. This also applies for SQL Azure, so if you need a custom time zone you'll have to manage that in the middle/front end tier.

One suggestion that we have is to review the new date/time function that AZURE SQL DATABASE provided as AT TIME ZONE and datetimeoffset you could find out the different time zones running the query: select * from sys.time_zone_info

For example, we could create the following function:

CREATE FUNCTION dReturnDate( @dFecha as datetime)


returns DATETIME


as


begin


DECLARE @D AS datetimeoffset


SET @D = CONVERT(datetimeoffset, @Dfecha) AT TIME ZONE 'W. Europe Standard Time'


RETURN CONVERT(datetime, @D);


end


Running the query DBO.dReturnDate(getdate()) you could observe the results. Please, verify the timezone that you are working on with select * from sys.time_zone_info.

6 Comments
Version history
Last update:
‎Mar 13 2019 06:13 PM
Updated by: