DAY function in SQL Server
The DAY function in SQL Server returns an integer that is the day of the month (from 1 to 31) from the time passed.
This article will show you in detail how to use DAY () DateTime () function in SQL Server with specific syntax and examples to better visualize and capture functions.
Describe
The DAY function in SQL Server returns an integer that is the day of the month (from 1 to 31) from the time passed.
Syntax
To use DAY function in SQL Server, we use the following syntax:
DAY(thoigian)
Parameters :
- thoigian: the time you want to retrieve the date value.
Note :
- The DAY function returns the result as an integer value.
- See also the DATENAME and DATEPART functions that return similar results.
- DAY can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.
For example
Take a look and explore some examples of DAY functions in SQL Server.
SELECT DAY('2019/04/28');
Result: 28
SELECT DAY('2019/03/31 10:05');
Result: 31
SELECT DAY('2019/04/01 10:05:18.621');
Result: 1
Previous article: DATEPART function in SQL Server
Next article: GETDATE function in SQL Server
4 ★ | 2 Vote
You should read it
- MIN function in SQL Server
- MAX function in SQL Server
- ABS function in SQL Server
- SUM function in SQL Server
- AVG function in SQL Server
- DATEPART function in SQL Server
- ROUND function in SQL Server
- DATENAME function in SQL Server
- MONTH function in SQL Server
- GETUTCDATE function in SQL Server
- FLOOR function in SQL Server
- SQL Server YEAR function