How to use date filter in sql query

I’m very new to Grafana. I’m going the route of writing custom sql queries to populate my panels (however I feel like there must be an easier way). Having said that, I’m noticing the dashboard values do not change when I use the default time selections Grafana gives. Do I have include date filter logic in the query?

from grafana_dwh_mux_dimensions
  batch_year='2023' and 
  batch_month='08' and 
  batch_day='25' and
group by viewer_os_family

This is what I think is right, but it does not return data.

Welcome @jamesbrooks3

version of grafana?
datasource type? mysql, mssql, postgres?

hi @yosiasz,

I’m using an athena db

Grafana v10.0.3

Is viewtime column utc?
Also what happens when you run this query in athena query tool ?

yes, according to the data dictionary it’s in UTC

I get this error:
error querying the database: error executing query: InvalidRequestException: line 3:18: mismatched input ‘=’. Expecting: { RespMetadata: { StatusCode: 400, RequestID: “d93db94c-b7ec-4fe3-8558-138939b894f2” }, AthenaErrorCode: “MALFORMED_QUERY”, Message_: “line 3:18: mismatched input ‘=’. Expecting: ” }

What did you run and where did you run it?

Hello @jamesbrooks3, I am rather new to Grafana myself. Have you attempted $__timeFilter() instead of date filter?

Start simple - remove that batch conditions and when you have working examole then add more complexity, e. g. batch conditions. You will see which step generates an error, so you will know what wrong.

Also use query inspector to check generated SQL syntax How To Use Grafana's Query Inspector to troubleshoot issues

this worked! thank you