--- description: "SYSDATETIMEOFFSET (Transact-SQL)" title: "SYSDATETIMEOFFSET (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/14/2017" ms.prod: sql ms.prod_service: "database-engine, sql-database, synapse-analytics, pdw" ms.reviewer: "" ms.technology: t-sql ms.topic: reference f1_keywords: - "SYSDATETIMEOFFSET_TSQL" - "SYSDATETIMEOFFSET" dev_langs: - "TSQL" helpviewer_keywords: - "date and time [SQL Server], SYSDATETIMEOFFSET" - "dates [SQL Server], functions" - "current date and time [SQL Server]" - "functions [SQL Server], time" - "system date and time [SQL Server]" - "system time [SQL Server]" - "SYSDATETIMEOFFSET function [SQL Server]" - "functions [SQL Server], date and time" - "time [SQL Server], functions" - "dates [SQL Server], current date and time" - "dates [SQL Server], system date and time" - "time zones [SQL Server]" - "time [SQL Server], system" ms.assetid: 8423c753-cebe-4edd-871d-0138e092199f author: LitKnd ms.author: kendralittle monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current" --- # SYSDATETIMEOFFSET (Transact-SQL) [!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)] Returns a **datetimeoffset(7)** value that contains the date and time of the computer on which the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is running. The time zone offset is included. For an overview of all [!INCLUDE[tsql](../../includes/tsql-md.md)] date and time data types and functions, see [Date and Time Data Types and Functions (Transact-SQL)](../../t-sql/functions/date-and-time-data-types-and-functions-transact-sql.md). ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ```syntaxsql SYSDATETIMEOFFSET ( ) ``` [!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)] ## Return Type **datetimeoffset(7)** ## Remarks [!INCLUDE[tsql](../../includes/tsql-md.md)] statements can refer to SYSDATETIMEOFFSET anywhere they can refer to a **datetimeoffset** expression. SYSDATETIMEOFFSET is a nondeterministic function. Views and expressions that reference this function in a column cannot be indexed. > [!NOTE] > [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] 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](../../includes/ssnoversion-md.md)] is running. The precision of this API is fixed at 100 nanoseconds. The accuracy can be determined by using the GetSystemTimeAdjustment() Windows API. ## Examples The following examples use the six [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] 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. ### A. Showing the formats that are returned by the date and time functions The following example shows the different formats that are returned by the date and time functions. ```sql SELECT SYSDATETIME() AS [SYSDATETIME()] ,SYSDATETIMEOFFSET() AS [SYSDATETIMEOFFSET()] ,SYSUTCDATETIME() AS [SYSUTCDATETIME()] ,CURRENT_TIMESTAMP AS [CURRENT_TIMESTAMP] ,GETDATE() AS [GETDATE()] ,GETUTCDATE() AS [GETUTCDATE()]; ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` SYSDATETIME() 2007-04-30 13:10:02.0474381 SYSDATETIMEOFFSET()2007-04-30 13:10:02.0474381 -07:00 SYSUTCDATETIME() 2007-04-30 20:10:02.0474381 CURRENT_TIMESTAMP 2007-04-30 13:10:02.047 GETDATE() 2007-04-30 13:10:02.047 GETUTCDATE() 2007-04-30 20:10:02.047 ``` ### B. Converting date and time to date The following example shows you how to convert date and time values to `date`. ```sql SELECT CONVERT (date, SYSDATETIME()) ,CONVERT (date, SYSDATETIMEOFFSET()) ,CONVERT (date, SYSUTCDATETIME()) ,CONVERT (date, CURRENT_TIMESTAMP) ,CONVERT (date, GETDATE()) ,CONVERT (date, GETUTCDATE()); ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` 2007-04-30 2007-04-30 2007-04-30 2007-04-30 2007-04-30 2007-04-30 ``` ### C. Converting date and time to times The following example shows you how to convert date and time values to `time`. ```sql SELECT CONVERT (time, SYSDATETIME()) AS [SYSDATETIME()] ,CONVERT (time, SYSDATETIMEOFFSET()) AS [SYSDATETIMEOFFSET()] ,CONVERT (time, SYSUTCDATETIME()) AS [SYSUTCDATETIME()] ,CONVERT (time, CURRENT_TIMESTAMP) AS [CURRENT_TIMESTAMP] ,CONVERT (time, GETDATE()) AS [GETDATE()] ,CONVERT (time, GETUTCDATE()) AS [GETUTCDATE()]; ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` SYSDATETIME() 13:18:45.3490361 SYSDATETIMEOFFSET()13:18:45.3490361 SYSUTCDATETIME() 20:18:45.3490361 CURRENT_TIMESTAMP 13:18:45.3470000 GETDATE() 13:18:45.3470000 GETUTCDATE() 20:18:45.3470000 ``` ## See Also [CAST and CONVERT (Transact-SQL)](../../t-sql/functions/cast-and-convert-transact-sql.md) [Date and Time Data Types and Functions (Transact-SQL)](../../t-sql/functions/date-and-time-data-types-and-functions-transact-sql.md)