MySQL fetches rows older than a week

MySQL, how can I only select rows that are older than a week?

I need to do this in order to create a system that deletes the old tmp files that I have saved in the database.

+3


source to share


3 answers


Try it,



select * from table
where DATEDIFF(now(),colname) > 7;

      

+6


source


select * from table
where (SELECT DATEDIFF(curtime(),col_name)) > 7

      



+2


source


SELECT * FROM `table` WHERE `created` < dateadd(week,-1,getdate())

      

+2


source







All Articles