GETUTCDATE Function

GETUTCDATE() represents the current UTC time (Universal Time Coordinate or Greenwich Mean Time)

  • It is a nondeterministic function, Views and expressions that reference this column cannot be indexed.

The current UTC time is derived from the current local time and the time zone setting in the operating system of the computer on which SQL Server is running.

The difference between GETDATE() and GETUTCDATE() is time zone number of the SQL Server machine.

For better understanding see the example:

DECLARE @local_time DATETIME;
DECLARE @gmt_time DATETIME;
SET @local_time = GETDATE();
SET @gmt_time = GETUTCDATE();
SELECT 'Server local time: '
   + CONVERT(VARCHAR(40),@local_time);
SELECT 'Server GMT time: '
   + CONVERT(VARCHAR(40),@gmt_time);
SELECT 'Server time zone: '
   + CONVERT(VARCHAR(40),
      DATEDIFF(hour,@gmt_time,@local_time));
GO

OUTPUT:

Server local time: Jun  2 2007 10:06PM
Server GMT time: Jun  2 2007  4:21PM
Server time zone: 6

GETDATE ()

  • It will return the date with your regional time or we can say, it returns the current system date and time.
  • If you are connected to the SQL server remotely then the timestamp displayed will be the timestamp of the remote machine and not your local machine.
  • It is a nondeterministic function.
  • Views and expressions that reference this column cannot be indexed.

GETUTCDATE ()

  • It will return the date and GMT time (Greenwich Mean Time).
  • GETUTCDATE () can be used to store the timestamp that is independent of Time Zones.
  • The current UTC time is derived from the current local time and the time zone setting in the operating system of the computer on which the instance of Microsoft SQL Server is running.
  • GETUTCDATE is a nondeterministic function.
  • Views and expressions that reference this column cannot be indexed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)