MySQL Get Last Day of Month from Date Example
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...
- How to Increase max_connections in MySQL?
- How to Install the PHP PDO MySQL Extension on Ubuntu 22.04?
- How to Install PHP MySQL on Linux Ubuntu?
- How to Install LEMP Stack Nginx, MySQL, PHP on Ubuntu?
- How to Change MySQL Root User Password Ubuntu?
- PHP 8 MySQL Form Validation Example
- How to Select First Row Only in PHP MySQL?
- How To Backup MySQL Database Using PHP Example