Skip to content

Latest commit

 

History

History
79 lines (61 loc) · 2.55 KB

File metadata and controls

79 lines (61 loc) · 2.55 KB
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
database-engine
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
DAY_TSQL
DAY
dev_langs
TSQL
helpviewer_keywords
date and time [SQL Server], DAY
dates [SQL Server], functions
DAY function [SQL Server]
dates [SQL Server], days
functions [SQL Server], date and time
dateparts [SQL Server], day
ms.assetid 2f4410ea-fd3e-4d69-ac4b-3b0091a084bc
caps.latest.revision 41
author edmacauley
ms.author edmaca
manager craigg
ms.workload Active

DAY (Transact-SQL)

[!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).

Topic link icon Transact-SQL Syntax Conventions

Syntax

DAY ( date )  

Arguments

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.

Return Type

int

Return Value

DAY returns the same value as DATEPART (day, date).

If date contains only a time part, the return value is 1, the base day.

Examples

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);  

See also

CAST and CONVERT (Transact-SQL)