| title | DAY (Transact-SQL) | ||||||
|---|---|---|---|---|---|---|---|
| description | DAY (Transact-SQL) | ||||||
| author | markingmyname | ||||||
| ms.author | maghan | ||||||
| ms.date | 07/30/2017 | ||||||
| ms.service | sql | ||||||
| ms.subservice | t-sql | ||||||
| ms.topic | reference | ||||||
| ms.custom |
|
||||||
| f1_keywords |
|
||||||
| helpviewer_keywords |
|
||||||
| dev_langs |
|
||||||
| monikerRange | >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb |
[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricsqldb]
This function returns an integer that represents the day (day of the month) of the specified date.
See Date and Time Data Types and Functions (Transact-SQL) for an overview of all [!INCLUDEtsql] date and time data types and functions.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
DAY ( date )
date
An expression that resolves to one of the following data types:
- date
- datetime
- datetimeoffset
- datetime2
- smalldatetime
- time
For date, DAY will accept a column expression, expression, string literal, or user-defined variable.
int
DAY returns the same value as DATEPART (day, date).
If date contains only a time part, DAY will return 1 - the base day.
This statement returns 30 - the number of the day itself.
SELECT DAY('2015-04-30 01:01:01.1234567'); This statement returns 1900, 1, 1. The date argument has a number value of 0. [!INCLUDEssNoVersion] interprets 0 as January 1, 1900.
SELECT YEAR(0), MONTH(0), DAY(0);