| title | SYSUTCDATETIME (Transact-SQL) | |||||||
|---|---|---|---|---|---|---|---|---|
| description | SYSUTCDATETIME returns a datetime2 value that contains the current date and time of the system. | |||||||
| author | MikeRayMSFT | |||||||
| ms.author | mikeray | |||||||
| ms.reviewer | randolphwest | |||||||
| ms.date | 10/20/2025 | |||||||
| ms.service | sql | |||||||
| ms.subservice | t-sql | |||||||
| ms.topic | reference | |||||||
| ms.custom |
|
|||||||
| f1_keywords |
|
|||||||
| helpviewer_keywords |
|
|||||||
| dev_langs |
|
|||||||
| monikerRange | >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric || =fabric-sqldb |
[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw-fabricsqldb]
Returns a datetime2 value that contains the date and time of the computer on which the instance of [!INCLUDE ssNoVersion] is running. The date and time is returned as UTC time (Coordinated Universal Time). The fractional second precision specification has a range from 1 to 7 digits. The default precision is 7 digits.
Consider:
-
SYSDATETIMEandSYSUTCDATETIMEhave more fractional seconds precision thanGETDATEandGETUTCDATE. -
SYSDATETIMEOFFSETincludes the system time zone offset. -
SYSDATETIME,SYSUTCDATETIME, andSYSDATETIMEOFFSETcan be assigned to a variable of any one of the date and time types.
For an overview of all [!INCLUDE tsql] date and time data types and functions, see Date and time data types and functions.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
SYSUTCDATETIME ( )
datetime2
[!INCLUDE tsql] statements can refer to SYSUTCDATETIME anywhere they can refer to a datetime2 expression.
SYSUTCDATETIME is a nondeterministic function. Views and expressions that reference this function in a column can't be indexed.
Note
[!INCLUDE ssNoVersion] obtains the date and time values by using the GetSystemTimeAsFileTime() Windows API. The accuracy depends on the computer hardware and version of Windows on which the instance of [!INCLUDE ssNoVersion] is running. The precision of this API is fixed at 100 nanoseconds. The accuracy can be determined by using the GetSystemTimeAdjustment() Windows API.
The following examples use the six [!INCLUDE ssNoVersion] system functions that return current date and time to return the date, time, or both. The values are returned in series; therefore, their fractional seconds might be different.
The following example shows the different formats that are returned by the date and time functions.
SELECT SYSDATETIME() AS [SYSDATETIME()],
SYSDATETIMEOFFSET() AS [SYSDATETIMEOFFSET()],
SYSUTCDATETIME() AS [SYSUTCDATETIME()],
CURRENT_TIMESTAMP AS [CURRENT_TIMESTAMP],
GETDATE() AS [GETDATE()],
GETUTCDATE() AS [GETUTCDATE()];[!INCLUDE ssResult]
SYSDATETIME() 2025-10-20 13:10:02.0474381
SYSDATETIMEOFFSET() 2025-10-20 13:10:02.0474381 -07:00
SYSUTCDATETIME() 2025-10-20 20:10:02.0474381
CURRENT_TIMESTAMP 2025-10-20 13:10:02.047
GETDATE() 2025-10-20 13:10:02.047
GETUTCDATE() 2025-10-20 20:10:02.047
The following example shows you how to convert date and time values to the date data type.
SELECT CONVERT (DATE, SYSDATETIME()),
CONVERT (DATE, SYSDATETIMEOFFSET()),
CONVERT (DATE, SYSUTCDATETIME()),
CONVERT (DATE, CURRENT_TIMESTAMP),
CONVERT (DATE, GETDATE()),
CONVERT (DATE, GETUTCDATE());[!INCLUDE ssResult]
2025-10-20
2025-10-20
2025-10-20
2025-10-20
2025-10-20
2025-10-20
The following example shows you how to convert date and time values to the time data type.
DECLARE @DATETIME AS DATETIME = GetDate();
DECLARE @TIME AS TIME;
SELECT @TIME = CONVERT (TIME, @DATETIME);
SELECT @TIME AS 'Time',
@DATETIME AS 'Date Time';[!INCLUDE ssResult]
Time Date Time
13:49:33.6330000 2025-10-20 13:49:33.633