MySQL: How to Find the First and the Last Day of the Month

MySQL has a lot of DATE and TIME related functions. If you want to find out the last day of the month, all you need to do is to use the inbuilt function names LAST_DAY.

Here’s an example:

SET @date:=’2014-08-11′;
SELECT LAST_DAY(@date) ASlast_day;


The above code will return a value: 2014-08-31

The problem is, there is no inbuilt function to find out the first day for a month. In this method, we’ll discuss the two methods to display the first day of the month. We’ll use the DATE_ADD and LAST_DAY function and the DATE_ADD and DAY functions.

Read the rest of the post here:

Leave a Reply

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