| title | DAY (Transact-SQL) | Microsoft Docs | ||||||
|---|---|---|---|---|---|---|---|
| ms.custom | |||||||
| ms.date | 07/30/2017 | ||||||
| ms.prod | sql-non-specified | ||||||
| ms.prod_service | database-engine, sql-database, sql-data-warehouse, pdw | ||||||
| ms.service | |||||||
| ms.component | t-sql|functions | ||||||
| ms.reviewer | |||||||
| ms.suite | sql | ||||||
| ms.technology |
|
||||||
| ms.tgt_pltfrm | |||||||
| ms.topic | language-reference | ||||||
| f1_keywords |
|
||||||
| dev_langs |
|
||||||
| helpviewer_keywords |
|
||||||
| ms.assetid | 2f4410ea-fd3e-4d69-ac4b-3b0091a084bc | ||||||
| caps.latest.revision | 41 | ||||||
| author | edmacauley | ||||||
| ms.author | edmaca | ||||||
| manager | craigg | ||||||
| ms.workload | Active |
[!INCLUDEtsql-appliesto-ss2008-all-md]
Returns an integer representing the day (day of the month) of the specified date.
For an overview of all [!INCLUDEtsql] date and time data types and functions, see Date and Time Data Types and Functions (Transact-SQL).
Transact-SQL Syntax Conventions
DAY ( date ) date
Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value. The date argument can be an expression, column expression, user-defined variable or string literal.
int
DAY returns the same value as DATEPART (day, date).
If date contains only a time part, the return value is 1, the base day.
The following statement returns 30. This is the number of the day.
SELECT DAY('2015-04-30 01:01:01.1234567'); The following statement returns 1900, 1, 1. The argument for date is the number 0. [!INCLUDEssNoVersion] interprets 0 as January 1, 1900.
SELECT YEAR(0), MONTH(0), DAY(0);