# DQL Query: Filtering Logs by Time Range Across Multiple Days

**URL:** <https://community.dynatrace.com/t/dql-query-filtering-logs-by-time-range-across-multiple-days/44141>\
**Category:** DQL\
**Tags:** dql, timeframe\
**Created:** [February 15, 2024, 11:31am UTC](https://community.dynatrace.com/t/dql-query-filtering-logs-by-time-range-across-multiple-days/44141 "2024-02-15T11:31:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JerryJ](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@JerryJ](https://community.dynatrace.com/u/JerryJ)\
**Post date:** [February 15, 2024, 11:31am UTC](https://community.dynatrace.com/t/dql-query-filtering-logs-by-time-range-across-multiple-days/44141/1 "2024-02-15T11:31:02Z")

</div>

Hi everyone, I’m trying to write a DQL query that filters the fetch logs by a specific time range across multiple days. For example, I want to retrieve only the logs from 22:00 to 07:00 for each day in a week, without having to change the query manually for each day. The documentation on the DT website shows how to use the timeframe parameter - fetch logs, timeframe:“2021-10-20T00:00:00Z/2021-10-28T12:00:00Z”, but it returns all the logs between the start and end dates, not the ones that match the time range I need per day. Is it possible to achieve this?

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [February 15, 2024, 6:09pm UTC](https://community.dynatrace.com/t/dql-query-filtering-logs-by-time-range-across-multiple-days/44141/2 "2024-02-15T18:09:03Z")

</div>

you can utilize getHour() function. e.g.:

```java
fetch logs, samplingRatio:1000
| filter getHour(timestamp)<7 or getHour(timestamp)>=22
| summarize {count()}, by: { bin(timestamp,10m)}

```

 ![krzysztof_hoja_0-1708020455588.png](https://global.discourse-cdn.com/dynatrace/original/2X/2/25fabff54a2fb4057d127b83643f8f5075343bea.png)

---

<div class="post-metadata">

**Author:** ![walterdelgado](https://avatars.discourse-cdn.com/v4/letter/w/958977/32.png) [@walterdelgado](https://community.dynatrace.com/u/walterdelgado)\
**Post date:** [April 30, 2025, 2:36am UTC](https://community.dynatrace.com/t/dql-query-filtering-logs-by-time-range-across-multiple-days/44141/3 "2025-04-30T02:36:38Z")

</div>

Hi&nbsp;krzysztof\_hoja

Do you know any filter for timeseries?

Regards,

Walter
