How can I calculate diff years between 2 dates using mysql function timestamdiff in my query builder? I tried to create sql custom dialect funtion but it doesn't work:
$dialect->registerCustomFunction(
'DATE_DIFF_YEARS',
function ($dialect, $expression) {
$arguments = $expression['arguments'];
return sprintf(
"TIMESTAMPDIFF(YEAR, %s, %s)",
$dialect->getSqlExpression($arguments[0]),
$dialect->getSqlExpression($arguments[1])
);
}
);