SQL DAY Function

SQL Day function will return an integer representing a specified date’s day, and the syntax is


The argument can be an expression that returns the date, or you can use the date and time directly. For this MySQL Day function example, We use this data.

Employee Table 1

SQL DAY Function Example

In this example, we will show you the possible ways to use the Day method

SELECT DAY('12-19-05') AS [DayExample 1]

-- Testing with Random DateTime 
SELECT DAY('2015-05-14 12:29:44.513') AS [DayExample 2]

-- Testing with Todays Date
Simple DAY Example 2

In this DateTime example, we will extract the Date from the Employee table using the DATEPART and Day functions.

      ,[FirstName] + ' '+ [LastName] AS [Full Name]
      ,DAY([HireDate]) AS [Today]
      ,DATEPART (day, [HireDate]) AS [TodayFromDatePart]
  FROM [Employee]

As you can observe that the DATEPART and Day functions return the same result.

SQL DAY Function 3

Remember, before Server 2012, people used the DATEPART to extract the day. But, in the 2012 version, Microsoft introduced the day function.

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.