Get current zone time using GETUTCDATE() function in instance of SQL Server.
Sometime we need to get the current datetime of the system where the instance of SQL server(client) is running regadless of SQL server placed in other country or different time zone. In this situaltion if we use GETDATE() function it will give you server current datetime. But using GETUTCDATE() function you can get the current date of the client location where the instance of the SQL server is running.
SELECT 'SYSDATETIME() ', SYSDATETIME();
SELECT 'SYSDATETIMEOFFSET()', SYSDATETIMEOFFSET();
SELECT 'SYSUTCDATETIME() ', SYSUTCDATETIME();
SELECT 'CURRENT_TIMESTAMP ', CURRENT_TIMESTAMP;
SELECT 'GETDATE() ', GETDATE();
SELECT 'GETUTCDATE() ', GETUTCDATE();
/* Returned:
SYSDATETIME() 2007-05-03 18:34:11.9351421
SYSDATETIMEOFFSET() 2007-05-03 18:34:11.9351421 -07:00
SYSUTCDATETIME() 2007-05-04 01:34:11.9351421
CURRENT_TIMESTAMP 2007-05-03 18:34:11.933
GETDATE() 2007-05-03 18:34:11.933
GETUTCDATE() 2007-05-04 01:34:11.933