Set default values for date Range as Today-7 & Today

We are using date range filter based on fields in Database as follows

select
a,
b,
c
from table1
where
created_at >= {{ date_from }} and
created_at <= {{ date_to }}

We need to set from date as Today - 1 and Today as ToDate

We can set values as specific date but not as today.

I tried with something like this but, getting error
created_at >= [[{{ date_from }}]]current_date

Can anybody please help me to solve this issue?

Hi @manish.joisar
You would have to add a comment syntax at the end of the optional clause:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#default-value-in-the-query
created_at >= [[{{ date_from }} --]]current_date

But your query looks so simple, that you should be able to use Field Filters and just add a default value:
https://www.metabase.com/learn/building-analytics/sql-templates/field-filters.html

Hello Flamber

Thanks for quick response.

To add default value, i need to add actual dates, but what i need is today's-7 & today's date
So next month when i look at it, it should show the default dates accordingly.
Which i didn't got an option in default values

@manish.joisar That's because you are using simple Date filter instead of Field Filter, which allows relative dates - exactly what you are looking for.

Thanks for your reply.

When i open default value, i have to select dates only

DateRange

@manish.joisar in "Filter widget type" change it to "Date Filter" - it should be called "All options", but that will give you a relative period.