DAYOFMONTH() MySQL Function – MySQL Tutorial

DAYOFMONTH() MySQL Function – MySQL Tutorial

Here You will learn how to use mysql DAYOFMONTH() function with syntax and examples. Today we are going to discuss about MySQL DAYOFMONTH() function with various examples.

When we need to get day of month of given date in mysql query that time we could use to mysql DAYOFMONTH () function. and it will return numeric value. We will take some example of with mysql various function like, CURDATE(), NOW() etc.


In MySQL, the DAYOFMONTH() is used to return the day of the month from a date. the DAYOFMONTH() function is a synonym for the DAYOFMONTH() function.

The “day of the month” is the value between 1 and 31. For example, if you provide a date of 2020-08-03, then the DAY () function 3 will return.


The DAYOFMONTH() function syntax is:


The date here is the date value that you want the day of the month from which you returned.


Now we take an example to demonstrate.

SELECT DAYOFMONTH('2020-06-18') AS 'Result';


| Result |
|     18 |


If there is a leading zero in the part of the day, then the leading zero has been left out of the result.

SELECT DAYOFMONTH('2018-02-01') AS 'Result';


| Result |
|      1 |

Example-3 | Database Example

Next database example, we take an example of removing part of the day with a column when running the query against the database.

 created_at AS create_date,
 DAYOFMONTH(created_at) AS day_of_month
 FROM users
 WHERE id= 112;


| create_date         | day_of_month |
| 2010-08-23 10:33:39 |           23 |

Example-4 | Current Date/Time

Let’s take another example , extracting part of the day from the current date and time (which is now returned using the () function).



| NOW()               | DAYOFMONTH(NOW())  |
| 2019-07-10 18:30:44 |         10         |

Example-4 | CURDATE() Function

Let’s take a another example of using CURDATE() function. Basically CURDATE() function returns only the date without time.



| 2019-05-15 |             15        |


Here, You have learned how to use mysql DAYOFMONTH() function with various examples.

You may like

  1. Get month name from date in mysql
  2. Get month number from month name in mysql
  3. mysql get day of week number from date
  4. Mysql Get Data Of Current Date, Week, Month, YEAR
  5. Query For Get Data Of Last Day, Week, Month, YEAR – Mysql

If you have any questions or thoughts to share, use the comment form below to reach us.


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *