Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » Date Time FunctionsRSS Feeds

DAY Function

Posted By: Sarita Patel     Category: SQL Server     Views: 3422

This article explains DAY function with different examples in sql server.

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. 


  
Share: 

 
 
 

Didn't find what you were looking for? Find more on DAY Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of DAY Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!