I need to apply this PHP Rule to remove records into a custom table

$query = "DELETE FROM $table_name WHERE Date < now() - INTERVAL 30 DAY;

I'not albe to figure out how to implement this line by applying

$wpdb->delete( $table, $where, $where_format );

I tried with this here below but it didn't work.

$wpdb->delete( $table_name, Date < now() - INTERVAL 30 DAY);

Please can you help me?

NOTE: Date: is a name of the column where date is written I need to remove all rows that are older than 30 days from "today"

1 Answer 1


I solved in this way

            "DELETE FROM $table_name WHERE Date < now() - INTERVAL 30 DAY")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.