DAY function is used to get DAY datepart of the specified date.
Syntax of DAY Function :
DAY(date)
date is an expression of type datetime or smalldatetime.
Return type of DAY function is an integer value.
Examples of DAY Function :
Example 1 : Use of DAY function in SELECT clause
SELECT DAY('10/30/2002')
Output
30
Above example displays a day of specified date string.
Example 2 : Use of DAY function in WHERE clause
SELECT ShipName, OrderDate
FROM Orders
WHERE DAY(OrderDate) >= 10
Output
ShipName OrderDate
Hanari Carnes 1996-07-10 00:00:00.000
Chop-suey Chinese 1996-07-11 00:00:00.000
Richter Supermarkt 1996-07-12 00:00:00.000
Wellington Importadora 1996-07-15 00:00:00.000
Above example displays orders made on or after 10th.