Reputation: 144
I have a table called filesUploaded, with a column called dataTimer of type varchar
.
When I record a new value in my table, I use the following command to enter the current date in timestamp format:
strtotime(date("Y-m-d H:i:s"));//Example: 145879957
To delete records that have more than 5 minutes in my table I use this syntax:
DELETE FROM filesUploaded WHERE dataTimer < (NOW() - INTERVAL 5 MINUTE)
But it is not working, what might be happening?
Upvotes: 2
Views: 757
Reputation: 2998
the issue is your storing it in the format of varchar .
you need to convert it to date format and the you can delete
DELETE FROM filesUploaded WHERE STR_TO_DATE(dataTimer,%Y-%m-%d %H:%M:%S) < (NOW() - INTERVAL 5 MINUTE)
Upvotes: 2