Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
DATENAME() Function in SQL Server
Next article icon

DAY() Function in SQL Server

Last Updated : 18 Jan, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

DAY() function :
This function in SQL Server is used to return the day of the month i.e, from 1st to 31st for date stated.

Features :

  • This function is used to find the day of the month for a date specified.
  • This function comes under Date Functions.
  • This function accepts only one parameter i.e, date.
  • This function can also include time with the stated date.

Syntax :

DAY(date)

Parameter :
This method accepts only one parameter as given below as follows.

  • date –Specified date from which the day of the month is to be returned.

Returns :
It returns the day of the month i.e, from 1st to 31st for a date specified.

Example-1 :
Using DAY() function and getting the day of the month from the date specified.

SELECT DAY('2020/01/02');

Output :

2

Example-2 :
Using DAY() function with a variable and getting the day of the month from the date specified.

DECLARE @date VARCHAR(50);  SET @date = '2020/01/05';  SELECT DAY(@date);

Output :

5

Example-3 :
Using DAY() function with date as parameter which includes time as well.

SELECT DAY('2018/11/22 07:44');

Output :

22

Example-4 :
Using DAY() function with a variable and a date as parameter which includes time as well.

DECLARE @date VARCHAR(50);  SET @date = '2020/11/30 23:59';  SELECT DAY(@date);

Output :

30

Application :
This function is used to find the day of the month from the date specified.



Next Article
DATENAME() Function in SQL Server
author
nidhi1352singh
Improve
Article Tags :
  • SQL
  • DBMS-SQL
  • SQL-Server

Similar Reads

  • ATN2() Function in SQL Server
    In this article, we are going to cover the ATN2()function in which we will see how we can get the arc tangent of two given numbers. Let's discuss one by one. // here val1 and val2 are input. Input : ATN2(val1, val2) Output : Arc tangent result. ATN2() : It is the function that returns the arc tangen
    1 min read
  • DATEADD() Function in SQL Server
    DATEADD() function : This function in SQL Server is used to sum up a time or a date interval to a specified date, then returns the modified date. Features : This function is used to sum up a time or a date interval to a date specified. This function comes under Date Functions. This function accepts
    3 min read
  • DATENAME() Function in SQL Server
    DATENAME() function : This function in SQL Server is used to find a given part of the specified date. Moreover, it returns the output value as a string. Features : This function is used to find a given part of the specified date.This function comes under Date Functions.This function accepts two para
    2 min read
  • DATEPART() Function in SQL Server
    DATEPART() function :This function in SQL Server is used to find a given part of the specified date. Moreover, it returns the output value as an integer.Features : This function is used to find a given part of the specified date.This function comes under Date Functions.This function accepts two para
    2 min read
  • LOG() Function in SQL Server
    The LOG() function returns the logarithm of a specified number or the logarithm of the number to the specified base. Syntax : LOG(number, base) Parameter : LOG() function accepts two-parameters as mentioned above and described below. number - This parameter hold a number which is greater than 0. bas
    1 min read
  • COUNT() Function in SQL Server
    The COUNT() function in SQL Server is a fundamental aggregate function used to determine the number of rows that match a specific condition. Counting rows provides valuable insights into data sets such as the total number of records, distinct values, or records meeting certain criteria. In this arti
    3 min read
  • SUM() Function in SQL Server
    The SUM() function in SQL Server is an essential aggregate function used to calculate the total sum of values in a numeric column. It aggregates data by summing up all values in the specified column for the rows that match the criteria of the query. In this article, We will learn about SUM() Functio
    3 min read
  • IIF() Function in SQL Server
    IIF() function judges or evaluates the first parameter and returns the second parameter if the first parameter is true, otherwise, it returns the third parameter. IIF() function used in SQL Server to add if-else logic to queries.IIF is not supported in dedicated SQL pools in Azure Synapse Analytics.
    2 min read
  • SQL Server ISNULL() Function
    The ISNULL() function in SQL Server is a powerful tool for handling NULL values in our database queries. It allows us to replace NULL values with a specified replacement value, ensuring that your queries return meaningful results even when data is missing. In this article, We will learn about the SQ
    4 min read
  • STR() Function in SQL Server
    The STR() function converts a numeric value to a character value. Syntax : STR(float_expression [, length [, decimal]]) Parameter : This method accepts three parameters as mentioned above and described below : float_expression : It is a numeric expression that evaluates to an approximate number with
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences