Date Field Filter Showing Option

Hi all,

I have a field as a timestamp, and I would like to pass to sql from parameter and in the query should be like that: data_partition >= cast('2021-01-23 21:00:00' as timestamp) . Just to get a filter showing the date option that I have in my table. The filter should be like the image below

image

Is it possible? I couldn't find any solution for that?

Best Regards

Hi @Fernando
Then you need to have the data is text in your database to show dropdown like that.
And you would have to create a sub-select, since the Field Filter generates SQL automatically.
https://www.metabase.com/learn/building-analytics/sql-templates/field-filters.html

Hi @flamber the filter should be created in dashboard or in the windows query edit?

How the subselect should be created? I could’nt find a way to do that and use ir in a filter, even in your link above.

@Fernando It would be some advanced selects you would have to do - also to account for multiple selects:
https://github.com/metabase/metabase/issues/7605
The simple version would just be to do something like this - again, it would require that you stored it as a string and used Field Type “Category” in Metabase > Admin > Data Model:

data_partition >= (select cast(mydatestring as timestamp) from mytable where {{fieldfilter}})