In this post explains how to use the DAY function in SQL Server (Transact-SQL) with syntax and examples.
In SQL Server (Transact-SQL), the DAY function returns the day of the month (a number from 1 to 31) given a date value.
The syntax for the DAY function in SQL Server (Transact-SQL) is:
DAY( date_value )
The date from which to extract the day of the month.
The DAY function can be used in the following versions of SQL Server (Transact-SQL):
Let's look at some SQL Server DAY function examples and explore how to use the DAY function in SQL Server (Transact-SQL).
For example:
SELECT DAY('2014/04/28');
Output: 28
SELECT DAY('2014/03/31 10:05');
Output: 31
SELECT DAY('2014/04/01 10:05:18.621');
Output: 1