Hey all,

Is there any way to check the time of insertion of a record. Means if i inserted a record in table on 03/21/2011 14:05:45 00:00 then is there any way to get this time after-wards

Recommended Answers

All 11 Replies

MySQL has a date type called timestamp which records the time of the last update of a row. Add such a field to your table. This field changes with every update, though. If you want to keep the insertion time, use a datetime field and a trigger which updates this field with the value now() after insertion.

ok.. but it will work for the records inserted from now on what about the previously inserted records?

Timestamp will capture the exact time when the record was changed for each record.

I don't know a way to find out past insertion times from the database. If you keep detailed database or web server logs you might be able to identify log entries with database records.

Then you need to write log of each and every transaction.

This is possible if number of tables are less and is highly impractical for a big database with hundreds of tables.

:( so there is no way to check the time of insertion of previously inserted records?

As i have already mentioned you can write log into another table.

@debasisdas: You are not answering the question.
@gulbano: Yes there is - if you have database or web server logs which recorded the data entry time.

gulbano there is no other way to track a record other than keeping log of it add a column in you table and insert the datetime of each record insertion and you will be able to keep the log of the future record insertions

Thanks all

@debasisdas: You are not answering the question.

I didn't get you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.