Getdate() seems wrong it shows UTC...
Published Jul 06 2020 01:25 AM 8,246 Views
Microsoft
Note the follow commands running in a on prem environment will return to you the date and time of your server region configuration, except for GetUTCdate, this one will return UTC per definition:
SELECT SYSDATETIME() 

    ,SYSDATETIMEOFFSET() 

    ,SYSUTCDATETIME() 

    ,CURRENT_TIMESTAMP 

    ,GETDATE() 

    ,GETUTCDATE();
 
 
As you can see here the doc confirms: "Returns the current database system timestamp as a datetime value without the database time zone offset. This value is derived from the operating system of the computer on which the instance of SQL Server is running."
 
This is my on-prem instance example. I am based in UTC+1, now is 09:15AM. So the results make sense as Fig. 1 shows:
UTC_onpre.png
 

Fig 1 OnPrem

 

If you are running against a PaaS environment such as Azure SQL DW. The same will show UTC, as Fig 2 shows:

UTC_Paas.png

Fig 2 ADW

 

So if you want to convert to your timezone you can use the following.

For example for IST timezone:

 

SELECT CONVERT(datetime, '03/14/2016 01:01:00')
AT TIME ZONE 'India Standard Time'


SELECT *
FROM sys.time_zone_info
where name like '%india%'

Other very good links about this:

 

https://techcommunity.microsoft.com/t5/azure-database-support-blog/lesson-learned-4-modifying-the-de...

 

https://thomaslarock.com/2016/03/sql-server-2016-time/

 

Liliam C Leme

Engineer UK

2 Comments
Copper Contributor

Congrats on publishing articles. Very proud of it!:smile:

Microsoft

Thanks @Sawamu . You know I highly respect you! I do appreciate this compliment coming from you.

Version history
Last update:
‎Jul 06 2020 01:30 AM
Updated by: