MySQL does not have a function that returns the first day of a date. However, you can use the 
LAST_DAY() function to calculate it.- Get the last day of the month of a date.
- Add 1 day to get the first day of the next month using DATE_ADD()function
- Subtract 1 month to get the first day of the month of the date.
The following query illustrates how to get the first day of 
2017-07-14.
To make it more convenient, you can develop a stored function named 
FIRST_DAY() as follows:
You then can call the 
FIRST_DAY() function as follows:
In this tutorial, you have learned how to use the MySQL 
LAST_DAY() function to get the last day of a month for a specified date. 
 
 
 
 
 
 
 
0 Comments