I run grafana locally with docker using “docker run -d -p 3000:3000 --name=grafana grafana/grafana-oss”.
I added a timeseries panel and i want this panel to display all data from the last 4 months until yesterday. This time range shall be valid only for this panel, i.e. I don’t want to use the dashboard time range selection to change what is displayed.
In the panel editor I found “Query options” and “Relative time”. There I can enter something like “now-4M” to get the data for the last 4 months. Unfortunately the upper bound here is “now”. I tried entering “now-4M-1d” or “now-1d-4M” or editing the json of the dashboard with " “timeTo”: “now-1d”,". Unfortunately it didn’t work.
You can’t “stack” the minus operation. I think that you should try “now-4M/M” or “now-120d/d” for your case.
Another option is to simply ignore Grafana’s time options and use the time range directly on your mysql query, something like:
select
*
from
yourtable t
where
/* Greater or equal to the start of last month */
t.date >= DATE_ADD(LAST_DAY(DATE_SUB(NOW(), INTERVAL 2 MONTH)), INTERVAL 1 DAY) and
/* Smaller or equal than one month ago */
t.date <= DATE_SUB(NOW(), INTERVAL 1 MONTH)