1

In Grafana I have a table that is populated by a MySQL query like this:

SELECT col1, col2 FROM Table WHERE StartDate = subdate(current_date, 1);

Effectively this gives me the results from the rows related to yesterday.

I want to have a date picker that defaults to yesterday, but that a user can select any date they want. (replaces the subdate(current_date, 1) with whatever date is selected. Is that possible? I've done a lot of searching but it's hard to look for because most Grafana/Date related information is in regards to graphing.

Steve Evans
  • 1,118
  • 2
  • 10
  • 16
  • 1
    What do you mean by "but that a user can select any date they want." Do you mean via the Grafana date picker? You can use the Grafana date picker range (from and to) variables in your where clause, is that what you are looking for? – Daniel Lee Sep 21 '17 at 16:12
  • 1
    @DanielLee yes, that is exactly what I'm saying. I updated the original question to clarify. Can you point me to a good example of that? I'm having a hard time finding info on it. – Steve Evans Oct 18 '17 at 15:20
  • The grafana docs discuss relevant built-in variables [here](http://docs.grafana.org/reference/templating/#the-timefilter-or-timefilter-variable). Your question may be a duplicate of [access variables from,to of the time range](https://stackoverflow.com/questions/46180387/grafana-global-variables-to-access-from-to-values-of-the-time-range). I could not get any of this to work for me though. – 7yl4r Jul 16 '18 at 22:02

0 Answers0