Custom fields: why is not working


If you put the code “(CAST(dateadd(‘day’, CAST(0 AS long), now()) AS date)-birth_date)/365.25”, to calculate an age in a native SQL Question it works, but if I put the same code in custom field in custom question, it doesn’t work.


We would prefer to use the custom question over native sql, but the custom field doesn’t seem to accept everything. Is this normal or is it a defect ?


Hi @Tania
Because the Custom Expressions are not functions in your database, but Metabase functions.

Hi @flamber

So we have to use SQL native question. Thanks a lot for the answer.

@Tania There’s a request for handling date/time in Custom Expressions, which would allow what you are trying to do with SQL: - upvote by clicking :+1: on the first post