DATETIMEOFFSETFROMPARTS (Transact-SQL)DATETIMEOFFSETFROMPARTS (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
指定された日付引数と時刻引数に対する datetimeoffset 値を返します。Returns a datetimeoffset value for the specified date and time arguments. 返される値は、精度引数によって指定された有効桁数と、オフセット引数によって指定されたオフセットを持ちます。The returned value has a precision specified by the precision argument, and an offset as specified by the offset arguments.
Transact-SQL 構文表記規則
Transact-SQL Syntax Conventions
構文Syntax
DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision )
注意
SQL Server 2014 以前の Transact-SQL 構文を確認するには、以前のバージョンのドキュメントを参照してください。To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
引数Arguments
yearyear
年を指定する整数式。An integer expression that specifies a year.
monthmonth
月を指定する整数式。An integer expression that specifies a month.
dayday
日を指定する整数式。An integer expression that specifies a day.
hourhour
時間を指定する整数式。An integer expression that specifies the hours.
minuteminute
分を指定する整数式。An integer expression that specifies the minutes.
secondsseconds
秒を指定する整数式。An integer expression that specifies the seconds.
fractionsfractions
秒の小数部を指定する整数式。An integer expression that specifies a fractional seconds value.
hour_offsethour_offset
タイム ゾーン オフセットの時間部分を指定する整数式。An integer expression that specifies the hour portion of the time zone offset.
minute_offsetminute_offset
タイム ゾーン オフセットの分部分を指定する整数式。An integer expression that specifies the minute portion of the time zone offset.
有効桁数 (precision)precision
DATETIMEOFFSETFROMPARTS
が返す datetimeoffset 値の有効桁数を指定する整数リテラル値です。An integer literal value that specifies the precision of the datetimeoffset value that DATETIMEOFFSETFROMPARTS
will return.
戻り値の型Return types
datetimeoffset( precision )datetimeoffset( precision )
注釈Remarks
DATETIMEOFFSETFROMPARTS
は、完全に初期化された datetimeoffset データ型を返します。DATETIMEOFFSETFROMPARTS
returns a fully initialized datetimeoffset data type. オフセット引数は、タイム ゾーンのオフセットを表します。The offset arguments represent the time zone offset. オフセット引数を省略すると、DATETIMEOFFSETFROMPARTS
はタイム ゾーン オフセットが 00:00
(つまり、タイム ゾーン オフセットなし) であるものと想定します。For omitted offset arguments, DATETIMEOFFSETFROMPARTS
assumes a time zone offset of 00:00
- in other words, no time zone offset. オフセット引数が指定される場合、DATETIMEOFFSETFROMPARTS
は両方の引数の値が指定され、両方とも正の値または両方とも負の値であるものと想定します。For specified offset arguments, DATETIMEOFFSETFROMPARTS
expects values for both arguments, and both values positive or negative. minute_offset の値が設定されていて、hour_offset の値が設定されていない場合、DATETIMEOFFSETFROMPARTS
はエラーになります。If minute_offset has a value and hour_offset has no value, DATETIMEOFFSETFROMPARTS
will raise an error. 他の引数が無効な値の場合、DATETIMEOFFSETFROMPARTS
はエラーになります。DATETIMEOFFSETFROMPARTS
will raise an error if the other arguments have invalid values. 必須引数の少なくとも 1 つが NULL
値である場合、DATETIMEOFFSETFROMPARTS
は NULL
を返します。If at least one required arguments has a NULL
value, then DATETIMEOFFSETFROMPARTS
will return NULL
. ただし、precision 引数が NULL
値の場合は、DATETIMEOFFSETFROMPARTS
はエラーを生成します。However, if the precision argument has a NULL
value, then DATETIMEOFFSETFROMPARTS
will raise an error.
分数 引数によって異なります、 有効桁数 引数。The fractions argument depends on the precision argument. たとえば、precision の値が 7 の場合、小数部分はそれぞれ 100 ナノ秒を表します。precision の値が 3 の場合、小数部分はそれぞれ 1 ミリ秒を表します。For example, for a precision value of 7, each fraction represents 100 nanoseconds; for a precision of 3, each fraction represents a millisecond. precision 値がゼロの場合、fractions の値もゼロでなければなりません。それ以外の場合、DATETIMEOFFSETFROMPARTS
はエラーを生成します。For a precision value of zero, the value of fractions must also be zero; otherwise, DATETIMEOFFSETFROMPARTS
will raise an error.
この関数は、リモート処理は実行することのできる SQL Server 2012 (11.x)SQL Server 2012 (11.x) サーバー上とします。This function is capable of being remoted to SQL Server 2012 (11.x)SQL Server 2012 (11.x) servers and above. SQL Server 2012 (11.x)SQL Server 2012 (11.x) 下のバージョンのサーバーには、リモート処理されません。It is not remoted to servers that have a version below SQL Server 2012 (11.x)SQL Server 2012 (11.x).
例Examples
A.A. 秒の小数部を使用しない場合の例An example without fractions of a second
SELECT DATETIMEOFFSETFROMPARTS ( 2010, 12, 31, 14, 23, 23, 0, 12, 0, 7 ) AS Result;
結果セットは次のようになります。Here is the result set.
Result
----------------------------------
2010-12-31 14:23:23.0000000 +12:00
(1 row(s) affected)
B.B. 秒の小数部を使用する場合の例Example with fractions of a second
この例は、fractions パラメーターと precision パラメーターの使用方法を示しています。This example shows the use of the fractions and precision parameters:
fractions の値が 5 のとき、precision の値が 1 であれば、fractions の値は 1 秒の 5/10 になります。When fractions has a value of 5, and precision has a value of 1, the value of fractions represents 5/10 of a second.
fractions の値が 50 のとき、precision の値が 2 であれば、fractions の値は 1 秒の 50/100 になります。When fractions has a value of 50, and precision has a value of 2, the value of fractions represents 50/100 of a second.
fractions の値が 500 で、precision の値が 3 の場合、fractions の値は 1 秒の 500/1000 を表します。When fractions has a value of 500, and precision has a value of 3, then the value of fractions represents 500/1000 of a second.
SELECT DATETIMEOFFSETFROMPARTS ( 2011, 8, 15, 14, 30, 00, 5, 12, 30, 1 );
SELECT DATETIMEOFFSETFROMPARTS ( 2011, 8, 15, 14, 30, 00, 50, 12, 30, 2 );
SELECT DATETIMEOFFSETFROMPARTS ( 2011, 8, 15, 14, 30, 00, 500, 12, 30, 3 );
GO
結果セットは次のようになります。Here is the result set.
----------------------------------
2011-08-15 14:30:00.5 +12:30
(1 row(s) affected)
----------------------------------
2011-08-15 14:30:00.50 +12:30
(1 row(s) affected)
----------------------------------
2011-08-15 14:30:00.500 +12:30
(1 row(s) affected)
関連項目See also
datetimeoffset (Transact-SQL)datetimeoffset (Transact-SQL)
AT TIME ZONE (Transact-SQL)AT TIME ZONE (Transact-SQL)