Search mysql by record creation date

Asked

Viewed 218 times

1

I want to do a mysql search by date of creation of all records, IE, I want to show the record and the date it was registered.

I’ve researched but what it always shows is the between but that’s not what I’m looking for.

What should I do?

  • 2

    As far as I know there’s no way automatic to do this, you need to create a column in the table and feed it, like in this question

1 answer

0

Your application has to include the record creation date - most frameowrks and application have a "time-stamped model" mixin, or equivalent, that can be used in your models - in such cases, the creation and last modification data are placed in specific columns in their tables.

And in these cases just do a query by this column, or place these columns in order-by.

If the application that creates the table and inserted the records did not do this, only with the data in the database it is not possible to know the time of creation of the records. If the automatic ID of the records is not a sequence (for example, if it is a UUID), not even the insertion order can be recovered.

If you happen to be a production database and have enabled the general logs (not only the error logs) - in this case, the insertion and change timestamps in the database can probably be extracted from these logs. However, this generation of logs is not active in the default configuration (see more here: https://stackoverflow.com/questions/5441972/how-to-see-log-files-in-mysql)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.