Aswathy S Aswathy S - 1 month ago 7
MySQL Question

how can i implement date conversions in typo3 repository methods

I have a query

SELECT * FROM `my_table`
WHERE DATEDIFF(CURDATE(), CAST(from_unixtime(tstamp) AS DATE)) >=365


How can I convert to repository method

$query = $this->createQuery();
$query->statement();
$query->matching(
$query->greaterThanOrEqual(????, 365)
);
return $query->execute();

Answer

You can just calculate that date with PHP:

$timestamp = time() - 86400 * 365;
$query->matching(
    $query->lessThanOrEqual('tstamp', $timestamp )
);
Comments