Adding time range to "Format as Table"

I have Grafana site that I want to add a “Format as Table” view that graphs the returned data. The data I am getting back is for the whole table and not for the specified date range.

here is the select that will work and graph all data:

select
   status as metric,
   count(*) as "num"
from activity
where gc101 = 1
group by 1
order by 1,2

So, in order to try to add the time range we added this:

and starttime > ${__from:date}
and starttime < ${__to:date}

here is the result from that:

grfna pr

What can i do to add a date range to a “Format as Table” view?

I am very comfortable with SQL so I would prefer to work with SQL rather than the point and click grafana interface. Is there some mode in grafana that makes working in SQL easier? The context of that is: grafana seems to throw away my changes when I change dropdowns.

welcome to the :grafana: forum, @lalajisananjaya

I think this will help. Use these macros inside your raw SQL query to Postgres and the Grafana frontend will expand them in accordance with the timepicker at the upper right of the dashboard. This way you can use the macros and dynamically change to to and from time periods: