Execute command denied to user for routine

I have this query and, for some reason, I am getting an error message when I write different functions related to dates (TO_DATE, DATEADD, DATESUB, and others):

SELECT
t.dates AS dates
, COUNT(DISTINCT t.client_id) AS client_id
FROM
(
SELECT
invoices.client_id AS client_id
, invoices.date AS dates
FROM invoices
) AS t
WHERE
TO_DATE(t.dates) BETWEEN t.dates AND DATEADD(month, '3', t.dates)
GROUP BY 1
ORDER BY 1

Sadly I could not find any solution. What could it be?

Thanks in advance!

Hi @str84355
The error is coming from your database, not Metabase. You'll need to fix the privileges on the database.

Could you please tell me what would be the permission we need to change in this case?

@str84355 https://stackoverflow.com/questions/6434573/mysql-execute-command-denied-to-user-localhost-for-routine-error