MySQL DAYOFMONTH() function
MySQL DAYOFMONTH() returns the day of the month for a given date. The day returned will be within the range of 1 to 31. If the date is ‘0000-00-00’, the function will return 0. The DAY() is the synonym of DAYOFMONTH().
This function is useful in -
- By using DAYOFMONTH(), you can filter and query data based on specific days of the month, which is useful for tasks like analyzing events or trends occurring on certain days.
- When entering or manipulating date data, DAYOFMONTH() helps users work with and validate the numeric day component.
- In calculations that involve the day component of dates, such as calculating the number of days left until a specific day, DAYOFMONTH() is essential.
- DAYOFMONTH() can be used to transform dates into a simplified numeric representation, which is useful for certain types of calculations.
- When plotting data on charts or graphs, DAYOFMONTH() can be used to label data points with the numeric day of the month.
- DAYOFMONTH() is used to identify the numeric day of the month in date-based analyses, helping you understand patterns or trends occurring on specific days.
Where date1 is a date.
MySQL Version: 8.0
Example: MySQL DAYOFMONTH() function
The following statement will return the day of the month from the specified date 2008-05-15.
mysql> SELECT DAYOFMONTH('2008-05-15'); +--------------------------+ | DAYOFMONTH('2008-05-15') | +--------------------------+ | 15 | +--------------------------+ 1 row in set (0.00 sec)
All Date and Time Functions :
Click here to see the MySQL Date and time functions.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook