Microsoft SQL Server

GETUTCDATE

Returns the current UTC date and time. This value is a datetime2(7) value. The UTC date and time is derived from the operating system of the computer on which SQL Server is running.

Syntax

GETUTCDATE ( )

Return Value

Returns the current UTC date and time as a datetime2(7) value.

Description

GETUTCDATE returns the current system time of the server. The time is returned in Coordinated Universal Time (UTC).

Examples

Example 1: Getting the current UTC date and time

SELECT GETUTCDATE();
Output:

2023-10-27 10:30:00.1234567

Example 2: Inserting the current UTC date and time into a table

Assume you have a table named EventLog with a column EventTimestamp of type datetime2.

CREATE TABLE EventLog (
    EventID INT IDENTITY(1,1) PRIMARY KEY,
    EventDescription VARCHAR(255),
    EventTimestamp DATETIME2
);

INSERT INTO EventLog (EventDescription, EventTimestamp)
VALUES ('User logged in', GETUTCDATE());

SELECT * FROM EventLog;
Output for SELECT * FROM EventLog;:

1 | User logged in | 2023-10-27 10:30:00.1234567

Remarks

Note: Ensure your server's operating system clock is accurate for reliable UTC time.

Applies to

See Also