How to get last 2 days records from table using Mysql Query?
In this post we will give you information about How to get last 2 days records from table using Mysql Query?. Hear we will give you detail about How to get last 2 days records from table using Mysql Query?And how to use it also give you demo for it if it is necessary.
We may sometimes require to get few days ago records from table like last 2 days, last 3 days, last 10 days or last 15 days etc. Most of developer choose other logic but we can easily get using mysql query(using CURDATE and INTERVAL).
In this example mysql query i have one table “elements” and columns are id, title, description, created_at(timestamps) and update_at, Now we will get all records of last 2 days.so you can fetch fields value using CURDATE and INTERVAL of mysql. In following example you can see how to select data of last two days.
SELECT * FROM 'elements'
WHERE created_at >= ( CURDATE() - INTERVAL 2 DAY )
Hope this code and post will helped you for implement How to get last 2 days records from table using Mysql Query?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs