DAY() function is used to get day from the date provided in the DAY() function. It gives the single day result in positive integer between first day of the month to last day of the month.
General Syntax is as follows:
SELECT DAY(DateParameter)
Get day from GETDATE() Function
We can get day from GETDATE() function which gives the day in integer from the current date.
SELECT DAY(GETDATE()) AS DayFromGetDate
Output

Get day from date provided as string in single quotes
We can get day from date provided as string in single quotes which gives the day in integer.
SELECT DAY('2022/01/31') AS DayFromDate
Output

Get day from table Column
We can get day from table having DATETIME data type. To get the day from the table columns, first we create a table and insert some rows and then we will get the day from that particular column.
USE HR GO CREATE TABLE tblEmployee ( EmpID INT PRIMARY KEY NOT NULL, EmpName VARCHAR(20), EmpGender VARCHAR(10), EmpAge INT, EmpSalary INT, EmpJoiningDate DATETIME ) GO
Let’s insert some records into tblEmployee table.
USE HR GO INSERT INTO tblEmployee VALUES (1,'Simon','Male',25,25000,'2015-01-01 22:04:49.400'), (2,'Dave','Male',29,15000,'2016-03-25 20:04:55.400'), (3,'Sara','Female',35,20000,'2017-05-01 18:04:35.400'), (4,'Julia','Female',36,35000,'2018-01-10 15:03:45.400'), (5,'Sam','Male',32,35000,'2020-03-20 10:02:25.400') GO
Below is the result of records of table tblEmployee.

Now, below is the query to get day from the EmpJoiningDate column of the table tblEmployee.
USE HR GO SELECT EmpName, EmpGender, EmpSalary, DAY(EmpJoiningDate) AS JoiningDay FROM tblEmployee GO
Output

Recommended Readings
- Advanced SQL Queries For Practice With Solution
- SQL Queries For Practice With Solution
- SQL Interview Questions and Answers
- STORED PROCEDURE in SQL Server
- How To Join Tables Data in SQL Server
- How to use Transaction in SQL Stored Procedure
- Difference Between IN and NOT IN Operators in SQL
- How To Modify Date in SQL Using DATEADD
- How To Get Year From Date in SQL Server
- How To Get Month From Date in SQL Server
- How To Get Day From Date in SQL Server
- How To Use ROW_NUMBER Function in SQL
- Date and Time Functions in SQL Server
- How To Find Nth Highest Salary in SQL Server
- How to Backup Table Using SELECT INTO Statement
- How To Use HAVING Clause in SQL Server
- Aggregate Functions in SQL Server
- How To Group Data Using Group By in SQL Server
- How To Truncate Table in SQL Server
- How To Delete Data From Table in SQL Server
- How To Update Table Data in SQL Server
- How To Sort Data Using Order By Clause in SQL
- How To Select Distinct Records in SQL Server
- How to Filter Data From Table in SQL Server
- Round Off Values Using Ceiling and Floor in SQL
- How To Find Square Root Of A Number in SQL Server
- How To Select Data From Table in SQL Server
- How To Insert Data in SQL Server Table
- How To Add NOT NULL Constraint in SQL Server
- How To Add Check Constraint on SQL Server Table
- How To Add Default Constraint on SQL Server Table
- Unique Key Constraint in SQL Server
- How to add Foreign Key Constraint in SQL Server
- How To Add Identity To SQL Server Table Column
- How to add Primary Key Constraint in SQL Server
- How To Create Alter and Drop Table in SQL Server
- How To Create Alter and Drop Database in SQL