Custom query does not work

Hi!

How I can get this raw query working?
There are no errors, but the afffected rows that should deleted does not delete.

class ProjectsRepository extends Repository
{

    public function purgeProjects($days = 14) {

        $time = time() - 3600 * 24 * $days;

        $q = $this->createQuery()->statement('DELETE FROM tx_myextension_domain_model_projects WHERE UNIX_TIMESTAMP(ctime) < ?', [$time]);
        $q->execute();

    }

}

The ctime field is type of datetime and I would´nt change it or add a extra new field with a unix timestamp for taht purpose.
(TYPO3-v12.4.28)

Try and echo the SQL and create a coresponding SELECT query, so you are sure the filter returns expected rows

Hi @heural!

Did @sorenmalling’s suggestion help you along in solving your issue?