Displaying dates

I want to display the average time between two date columns in a dashboard.
The custom expression I’m using is:
Average([Created] - [Agreement → Start Date])
This outputs e.g. “0 years 0 mons 224 days 30 hours 8 mins 38.071429 secs”. I would like to display this as days only, is there a way to do this in the custom expression builder?

Hi @trymsk

Metabase does currently don’t have date functions to handle this:
https://github.com/metabase/metabase/issues/11330 - upvote by clicking :+1: on the first post
And it would perhaps also require casting:

Currently the behavior is very different depending on which database type you’re querying. On H2 it works, but shows an integer (possibly unix timestamp) on MySQL, and shows as formatted time on Postgres (which I’m guessing you’re using).

1 Like