Calculate the AVG temperature only of working hours (8:00-18:00)


I’m new to Grafana and I want to use it to display some graphs (e.g. Gauge) in Home Assistant. My database is influxDB and I just want to calculate average temperature in working hours. That is, if I select the last 24 hours or the last 2 days as the time range in Grafana, I only want to consider the temperature data in the working hours(e.g. 8:00-18:00 and ignore the rest) when calculating the average temperature.
is there a way to do that?
Thanks in advance!