SQL Server Tutorial SQL Server Advanced SQL Server Database SQL Server References

SQL Server GETUTCDATE() Function



The SQL Server (Transact-SQL) GETUTCDATE() function returns the current date and time as UTC time (Coordinated Universal Time). This function derives this value from the operating system of the computer on which the instance of SQL Server runs.

The GETUTCDATE() function returns the system date and time in the format 'yyyy-mm-dd hh:mi:ss.mmm'.

Syntax

GETUTCDATE()

Parameters

No parameter is required.

Return Value

Returns the current date and time.

Example 1:

The example below shows the usage of GETUTCDATE() function.

SELECT GETUTCDATE();
Result: '2021-12-27 05:11:57.123'

Example 2:

Consider a database table called EmployeeLogin with the following records:

EmpIDNameLogin Stamp
1John2019-10-25 09:20:38.414
2Marry2019-10-25 09:21:05.854
3Jo2019-10-25 09:24:35.123
4Kim2019-10-25 09:25:24.321
5Ramesh2019-10-25 09:27:16.659

To insert a new record in this table, the following statement can be used.

INSERT INTO EmployeeLogin 
VALUES (6, 'Suresh', GETUTCDATE());

-- see the result
SELECT * FROM EmployeeLogin;

This will produce a result similar to:

EmpIDNameLogin Stamp
1John2019-10-25 09:20:38.414
2Marry2019-10-25 09:21:05.854
3Jo2019-10-25 09:24:35.123
4Kim2019-10-25 09:25:24.321
5Ramesh2019-10-25 09:27:16.659
6Suresh2019-10-25 09:28:19.354

❮ SQL Server Functions