SQL Server SYSUTCDATETIME Function

Savigo
You organize your data. Now organize your savings.
Set savings goals, track your progress, and stay on course.
Get Savigo for iPhone 

Summary: in this tutorial, you will learn how to use the SYSUTCDATETIME() function to get the current system date and time as UTC time.

SQL Server SYSUTCDATETIME() function #

The SYSUTCDATETIME() function returns a value of DATETIME2 that represents the current system date and time of the server on which the SQL Server instance is running. The datetime is in Coordinated Universal Time (UTC).

Here is the syntax of the SYSUTCDATETIME() function:

SYSDATETIME()

For example, to get the current date and time in UTC you use the following statement:

SELECT 
   SYSUTCDATETIME() utc_time;

The output is as follows:

2019-05-03 00:50:06.1821224

Notice that the SYSUTCDATETIME() function has more fractional seconds precision than the GETUTCDATE() function.

SQL Server SYSUTCDATETIME() function examples #

A) Returning the current system date as UTC time example #

The following example uses the CONVERT() function to convert the result of the SYSUTCDATETIME() function to the current date as UTC time:

SELECT 
    CONVERT(DATE, SYSUTCDATETIME()) utc_date;

Here is the result:

utc_date
----------
2019-05-03

(1 row affected)

B) Returning the current system time as UTC time example #

This example converts the result of the SYSUTCDATETIME() function to the current date as UTC time:

SELECT 
    CONVERT(DATE, SYSUTCDATETIME()) utc_time;

The following shows the output:

utc_time
----------
2019-05-03

(1 row affected)

In this tutorial, you have learned how to use the SQL Server SYSUTCDATETIME() function to get the current system date and time as UTC time.

Was this tutorial helpful?