MONTH() Function Examples – MySQL

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

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

Let’s see, if you give a date of 2019-07-11 in MONTH() function, it will return the 7 month. The MySQL MONTH() function returns only numeric value.

MySQL MONTH() Function

In MySQL, the MONTH() is used to return the month from a date. The MONTH() is return a value between 1 and 12.

The MONTH() is return a value between 1 and 12. For example, if you provide a date of 2020-08-03, then the DAY () function 8 will return.


The MONTH() function syntax is:


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


Now we take an example to demonstrate.

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


| Result |
|     8  |


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

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


| Result |
|      8 |

Example-3 | Database Example

For some time we want to fetch a record / data from the mysql database table. When we need to get the name of month a table in the database. In that case we use MONTH() with mysql queries.

Next, we take example-2, in this example we will fetch MONTH of database table name users where column name is created_at.

 created_at AS create_date,
 MONTH(created_at) AS month
 FROM users
 WHERE id= 112;


| create_date         | month        |
| 2010-08-23 10:33:39 |           8  |

Example-4 | Current Date/Time

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



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

Example-4 | CURDATE() Function

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



| CURDATE()  | MONTH(CURDATE())      |
| 2019-05-15 |              5        |


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

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

Spread the love

Be First to Comment

Leave a Reply

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