SYSUTCDATETIME (Transact-SQL)SYSUTCDATETIME (Transact-SQL)
適用対象:Applies to: SQL ServerSQL Server (サポートされているすべてのバージョン)
SQL ServerSQL Server (all supported versions)
Azure SQL データベースAzure SQL Database
Azure SQL データベースAzure SQL Database
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
Parallel Data WarehouseParallel Data Warehouse
Parallel Data WarehouseParallel Data Warehouse
SQL ServerSQL Server (サポートされているすべてのバージョン)
SQL ServerSQL Server (all supported versions)
Azure SQL データベースAzure SQL Database
Azure SQL データベースAzure SQL Database
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
Parallel Data WarehouseParallel Data Warehouse
Parallel Data WarehouseParallel Data Warehouse
返します、 datetime2 いるコンピューターの日時を表す値のインスタンス SQL ServerSQL Server が実行されています。Returns a datetime2 value that contains the date and time of the computer on which the instance of SQL ServerSQL Server is running. 日付と時刻が UTC 時刻 (世界協定時刻) として返されます。The date and time is returned as UTC time (Coordinated Universal Time). 秒の小数部の有効桁数は 1 ~ 7 桁の範囲で指定できます。The fractional second precision specification has a range from 1 to 7 digits. 既定の有効桁数は 7 桁です。The default precision is 7 digits.
注意
1 秒未満の有効桁数で比較すると、SYSDATETIME と SYSUTCDATETIME の方が GETDATE と GETUTCDATE よりも高い精度を得ることができます。SYSDATETIME and SYSUTCDATETIME have more fractional seconds precision than GETDATE and GETUTCDATE. SYSDATETIMEOFFSET には、システムのタイム ゾーン オフセットが含まれます。SYSDATETIMEOFFSET includes the system time zone offset. SYSDATETIME、SYSUTCDATETIME、および SYSDATETIMEOFFSET は、date 型と time 型のいずれか 1 つの変数に割り当てることができます。SYSDATETIME, SYSUTCDATETIME, and SYSDATETIMEOFFSET can be assigned to a variable of any one of the date and time types.
すべての概要については Transact-SQLTransact-SQL日付と時刻のデータ型および関数を参照してください 日付と時刻のデータ型および関数です。For an overview of all Transact-SQLTransact-SQL date and time data types and functions, see Date and Time Data Types and Functions.
Transact-SQL 構文表記規則
Transact-SQL Syntax Conventions
構文Syntax
SYSUTCDATETIME ( )
注意
SQL Server 2014 以前の Transact-SQL 構文を確認するには、以前のバージョンのドキュメントを参照してください。To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
戻り値の型Return Type
datetime2datetime2
注釈Remarks
Transact-SQLTransact-SQL ステートメントを参照できます SYSUTCDATETIME を参照できる任意の場所、 datetime2 式です。statements can refer to SYSUTCDATETIME anywhere they can refer to a datetime2 expression.
SYSUTCDATETIME は非決定的関数です。SYSUTCDATETIME is a nondeterministic function. この関数を列内で参照するビューと式には、インデックスを付けることができません。Views and expressions that reference this function in a column cannot be indexed.
注意
SQL ServerSQL Server は、GetSystemTimeAsFileTime() Windows API を使用して日付と時刻の値を取得します。obtains the date and time values by using the GetSystemTimeAsFileTime() Windows API. 精度は、SQL ServerSQL Server のインスタンスが実行されているコンピューター ハードウェアおよび Windows のバージョンによって異なります。The accuracy depends on the computer hardware and version of Windows on which the instance of SQL ServerSQL Server is running. この API の精度は 100 ナノ秒で固定されます。The precision of this API is fixed at 100 nanoseconds. 精度は、GetSystemTimeAdjustment() Windows API を使用して確認できます。The accuracy can be determined by using the GetSystemTimeAdjustment() Windows API.
例Examples
次の例では、現在の日付と時刻を返す 6 つの SQL ServerSQL Server システム関数を使用して、日付、時刻、またはその両方を取得しています。The following examples use the six SQL ServerSQL Server 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.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.
SELECT SYSDATETIME() AS [SYSDATETIME()]
,SYSDATETIMEOFFSET() AS [SYSDATETIMEOFFSET()]
,SYSUTCDATETIME() AS [SYSUTCDATETIME()]
,CURRENT_TIMESTAMP AS [CURRENT_TIMESTAMP]
,GETDATE() AS [GETDATE()]
,GETUTCDATE() AS [GETUTCDATE()];
結果セットは次のようになります。Here is the result set.
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.B. 日付と時刻を日付に変換するConverting date and time to date
次の例では、日付と時刻の値を date
に変換する方法を示します。The following example shows you how to convert date and time values to date
.
SELECT CONVERT (date, SYSDATETIME())
,CONVERT (date, SYSDATETIMEOFFSET())
,CONVERT (date, SYSUTCDATETIME())
,CONVERT (date, CURRENT_TIMESTAMP)
,CONVERT (date, GETDATE())
,CONVERT (date, GETUTCDATE());
結果セットは次のようになります。Here is the result set.
2007-04-30
2007-04-30
2007-04-30
2007-04-30
2007-04-30
2007-04-30
C.C. 日付と時刻の値を時刻に変換するConverting date and time values to time
次の例では、日付と時刻の値を time
に変換する方法を示します。The following example shows you how to convert date and time values to time
.
DECLARE @DATETIME DATETIME = GetDate();
DECLARE @TIME TIME
SELECT @TIME = CONVERT(time, @DATETIME)
SELECT @TIME AS 'Time', @DATETIME AS 'Date Time'
結果セットは次のようになります。Here is the result set.
Time Date Time
13:49:33.6330000 2009-04-22 13:49:33.633
関連項目See Also
CAST および CONVERT (Transact-SQL) CAST and CONVERT (Transact-SQL)
日付と時刻のデータ型および関数 (Transact-SQL) Date and Time Data Types and Functions (Transact-SQL)
AT TIME ZONE (Transact-SQL)AT TIME ZONE (Transact-SQL)