Use datediff in metabase

I’m writing a SQL query and I need to calculate the differece between two dates (in days). This is what I’m trying:

select datediff(day, {{end_date}}, {{start_date}})

In which end_date and start_date are variables (date type). But I’m getting the following error: “Incorrect parameter count in the call to native function ‘datediff’”

I really don’t know what might be wrong, any ideas?
Best regards.

Hi @Larissa
I’m not sure which database you’re querying, but the error looks like MySQL, which only supports two parameters:

Thank you, i’ts MySQL indeed. When I try:
select datediff({{end_date}}, {{start_date}})
The error message disappears, but the result isn’t right… selecting {{end_date}} as may 31, 2021 and {{start_date}} as may 1, 2021, I had the result equals to 54 :confounded:

Post “Diagnostic Info” from Admin > Troubleshooting, and which version of MySQL you are querying.
Try inputting the values manually. I cannot reproduce:

I realized that I was putting different dates as default, therefore the result was wrong. Now it’s working fine. Thank you for your help.