MySQL Get Last Day of Month from Date Example

01-Feb-2022

.

Admin

Hi Friends,

I am going to explain you example of MySQL get last day of month from date example. You will learn get last day of month from date in SQL query. I would like find record last day of month from date in MySQL. This article will give you simple example of get last day of month from date record in mysql.

Use the LAST_DAY() function if you want to retrieve the last day of the month for a date in MySQL. This function takes one argument – the date, either as an expression returning a date/datetime/timestamp value or the name of a date/datetime/timestamp column. In our example, we use the sale_date column. It’s of the date data type.

We will use get search how to find the last day of the month for a given date in MySQL.

Table : users


Solution SQL Query:

SELECT

id,

name,

email,

created_at,

DATE_ADD(LAST_DAY(created_at),INTERVAL 1 DAY) as first_date_of_month,

DATE(LAST_DAY(created_at + INTERVAL 1 MONTH)) as last_date_of_month

FROM `users`

Output:

I hope it will help you...

#MySQL