I have a Rails application that uses MYSQL as a database. For some conditions, I have to delete all records from the table that were stored exactly 2 hours before the current time.
My request:
DELETE FROM TABLE_NAME WHERE (NOW() - created_at) > 7200;
Here create_at is the datetime column type. Saving the value in the format "2012-12-04 06:39:44"
My problem is that the above query retrieves the records, even if the record creation time is only 40-50 minutes and deleted. The only problem is that the record was deleted after it reached 40-50 minutes to create time.
Can someone fix my request. I want a MySQL solution. Please help me
source share