How can we link Grafana time filter with our SQL query?

We have created a dashboard using SQL queries in Grafana. We want to link Grafana in-built time filter with our dashboard so that we can filter data as required. Kindly guide how can we map it? Thank you.

1 Like

Thanks. Can you also guide how to create global variable for this? And how to map it with our dashboard/Query?

they are built in, and you can call them from your query

For PostgreSQL, the syntax to include template variables looks like this:
SELECT * FROM "ElectricPowerOperations" WHERE "type" IN ('Demand') AND "region" IN (${region}) AND $__timeRange(time)

More examples here.

1 Like