Timestamp filter via creating a variable

Hello,

I would like to create a variable selecting a precise timestamp.

Let's take an example :
In my variable, I want to select a precise timestamp of 7 days like this one below :

BETWEEN '2022-04-26T16:04:48.158Z' AND '2022-05-03T16:04:48.158Z'

When a selected a filter field, I can put 7 days, but it start from the beginning of the day (midnight).

So my question is, Can we implement this sql "BETWEEN (NOW() - '7 DAYS'::INTERVAL) AND NOW()" in a variable ?

Thanks for your reponses

Hi @Zikki
Sounds like you perhaps just want a Number filter, where you can define the amount of days:
BETWEEN (NOW() - CONCAT({{numberdays}},' DAYS')::INTERVAL) AND NOW()

1 Like

Thanks for your answer.

It is a good solution. However, can we implement in the variable {{numberdays}} a special dropdown made by my own ? (Not related to any table of my database)

For example, I want to create a dropdown with the values from 1 to 31. This will avoid to the endUser tapping a bad entry.

@Zikki No, that's not supported currently. You can add a case-clause, so if the value is bad, then it gets corrected.

Thank you for your answer :slight_smile: