Have a date field in your table which includes the date the record was inserted, try a TIMESTAMP data type, for our example our field is called ‘DATE_ADDED’ and then use the DATEDIFF MySQL function.

Then run the following type of query:

SELECT <columns>
FROM <table>
WHERE DATEDIFF(NOW( ), DATE_ADDED) <28

Which will display all records which are less than 28 days old

How to display database records which are so many days old
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *

45 − forty two =