# Grafana Mysql query, data filtter between hours

**URL:** <https://community.grafana.com/t/grafana-mysql-query-data-filtter-between-hours/72713>\
**Category:** MySQL\
**Tags:** timestamp, query-help\
**Created:** [September 20, 2022, 11:03am UTC](https://community.grafana.com/t/grafana-mysql-query-data-filtter-between-hours/72713 "2022-09-20T11:03:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![srakeshaws](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@srakeshaws](https://community.grafana.com/u/srakeshaws)\
**Post date:** [September 20, 2022, 11:03am UTC](https://community.grafana.com/t/grafana-mysql-query-data-filtter-between-hours/72713/1 "2022-09-20T11:03:29Z")

</div>

i have data on mysql db, i want to display the data between 09:00:00AM to 18:00:00 on grafana.  
…

```auto
id | service_id | time
--- |-------------- | -------------------
1 | ABCDO | 2017-01-12 11:23:22
2 | PMKOP | 2017-01-12 11:20:22
3 | PMKOP | 2017-01-12 11:22:20
4 | MPLWK | 2017-01-12 11:22:48
5 | PMKOP | 2017-01-12 11:23:12
6 | SPLDK | 2017-01-12 13:23:22
7 | MPLWK | 2017-02-23 14:33:23
8 | ABCDO | 2017-02-12 11:23:11
9 | PMKOP | 2017-03-12 11:23:14
10 | MPLWK | 2017-02-24 10:23:18
11 | SPLDK | 2017-03-12 19:23:28
12 | ABCDO | 2017-04-12 11:23:33
13 | MPLWK | 2017-02-27 17:23:33
14 | SPLDK | 2017-04-13 11:23:45
15 | PMKOP | 2017-04-14 19:23:17
16 | SPLDK | 2017-05-18 09:23:19
17 | MPLWK | 2017-02-28 19:23:22

```

i m using below command in grafana, but getting whole day results instead of hours data. is there any way to add time interval in grafana ?

```auto
SELECT
  $__timeGroupAlias(time,$__interval),
  service_id as "metriC",
  count(id) AS "me_id"
FROM report
WHERE
  time between $__timeFrom() AND $__timeTo()
GROUP BY 1,2
ORDER BY $__timeGroup(time,$__interval)

```

im expecting output on grafana be as below.

```auto
morning : 14 
evening : 3

```

**Please avoid posting in the Grafana parent category. Whenever possible choose a subcategory.**

THANK YOU!!

~ the grafana team
