DAY (Transact-SQL)DAY (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
この関数は、指定された date の日 (月の日にち) を表す整数を返します。This function returns an integer that represents the day (day of the month) of the specified date.
Transact-SQLTransact-SQL の日付と時刻のあらゆるデータ型と関数に関する概要については、「日付と時刻のデータ型および関数 (Transact-SQL)」を参照してください。See Date and Time Data Types and Functions (Transact-SQL) for an overview of all Transact-SQLTransact-SQL date and time data types and functions.
Transact-SQL 構文表記規則
Transact-SQL Syntax Conventions
構文Syntax
DAY ( date )
注意
SQL Server 2014 以前の Transact-SQL 構文を確認するには、以前のバージョンのドキュメントを参照してください。To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
引数Arguments
datedate
次のいずれかのデータ型に解決される式。An expression that resolves to one of the following data types:
- datedate
- datetimedatetime
- datetimeoffsetdatetimeoffset
- datetime2datetime2
- smalldatetimesmalldatetime
- timetime
date の場合、DAY
では、列式、式、文字列リテラル、ユーザー定義の変数が受け入れられます。For date, DAY
will accept a column expression, expression, string literal, or user-defined variable.
戻り値の型Return Type
intint
戻り値Return Value
DAY は DATEPART(day, date) と同じ値を返します。DAY returns the same value as DATEPART (day, date).
date に時刻部分のみが含まれる場合、DAY
は基本の日である 1 を返します。If date contains only a time part, DAY
will return 1 - the base day.
例Examples
このステートメントは、日にち自体の数である 30
を返します。This statement returns 30
- the number of the day itself.
SELECT DAY('2015-04-30 01:01:01.1234567');
このステートメントは 1900, 1, 1
を返します。This statement returns 1900, 1, 1
. date 引数の数値は 0
になります。The date argument has a number value of 0
. SQL ServerSQL Server は、0
を 1900 年 1 月 1 日と解釈します。interprets 0
as January 1, 1900.
SELECT YEAR(0), MONTH(0), DAY(0);
関連項目See also
CAST および CONVERT (Transact-SQL)CAST and CONVERT (Transact-SQL)