In this tutorial, we will see how to get the last 15 days records in MySQL PHP. In PHP, you can use INTERVAL to get the last 15 days record from the database table. For MySQL query, we use the INTERVAL operator. It is mainly used to calculate the date and time values.
So, let's see SQL query to get last 15 days records, get 15 days data in laravel 6/7/8, how to get last 15 days data in PHP from MySQL Database.
Using SQL query to get data for the current month in MySQL.
id | order_date | amount | Orders
---+------------+--------+-------
1 | 2022-02-01 | 150 | 2
2 | 2022-02-02 | 200 | 4
3 | 2022-03-03 | 100 | 1
4 | 2022-03-04 | 300 | 5
5 | 2022-04-05 | 200 | 3
7 | 2022-04-06 | 190 | 7
In your table, the record needs to be like date and month.
select * from users
where order_date > now() - INTERVAL 15 day;
In the above query, we use the now() function to get the current date, and the INTERVAL() function to get the last 15 days records.
Using the below MySQL query you can get the new users in the last 15 days.
select * from users where created_at > now() - INTERVAL 15 day;
You might also like :
In this article, we will see a laravel 8 pdf generate example. For generating PDF file we will use the laravel-dompdf pa...
Oct-17-2020
Today I will show you how to create ajax crud operations in laravel. In laravel 6/7 ajax crud operation, we can perform...
May-14-2020
Have you ever seen those pop-up boxes on websites? They're called modal forms, and they make it easier to do things...
Jan-04-2023
In this article, we'll learn how to resolve the "419 page expired" error in Laravel. You might have encoun...
Jun-28-2020