Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get last 3 days records from database without today?

I am using this code:

WHERE date > DATE_SUB(CURDATE(), INTERVAL 3 DAY)

And result will be like this:

2022-05-12
2022-05-11
2022-05-10

But I want this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

2022-05-11
2022-05-10
2022-05-09

>Solution :

Use a range here:

WHERE date < CURDATE() AND date >= DATE_SUB(CURDATE(), INTERVAL 3 DAY)

Assuming today’s date be 2022-05-12, the above logic would exclude this date but include the three previous days, from 11th May to 9th May.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading