"before now" date filter

Hi,

How could I create a query with all data before (or after) now. I’d like the SQL NOW(), not to have to have the date every day.
The “Before” filter use a fixed date as parameter.

Can I do that easily ?

Hi @camilleroux

If you’re using it SQL, then you can use Optional Clauses with Complex Default Value (depending on your database, you might use # or -- for comments).

SELECT * FROM table
WHERE 1=1
AND column < [[{{date_filter}} --]] CURRENT_DATE()

There’s an issue, so you cannot use Complex Default Value with Field Filters.

If you’re using QB, then the work-around is to use “Previous” or “Next”, and set it to “99999” “Days”.

There’s a couple of requests open for relative filters - go and upvote by clicking :+1:
https://github.com/metabase/metabase/issues/6433
https://github.com/metabase/metabase/issues/4083#issuecomment-283915746

2 Likes