# use controls offered by the user interface to select your query time frame in DQL

**URL:** <https://community.dynatrace.com/t/use-controls-offered-by-the-user-interface-to-select-your-query-time-frame-in-dql/53464>\
**Category:** Developer Q&A Forum\
**Created:** [September 23, 2025, 3:32pm UTC](https://community.dynatrace.com/t/use-controls-offered-by-the-user-interface-to-select-your-query-time-frame-in-dql/53464 "2025-09-23T15:32:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lejil](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@Lejil](https://community.dynatrace.com/u/Lejil)\
**Post date:** [September 23, 2025, 3:32pm UTC](https://community.dynatrace.com/t/use-controls-offered-by-the-user-interface-to-select-your-query-time-frame-in-dql/53464/1 "2025-09-23T15:32:19Z")

</div>

How can I use controls offered by the user interface to select your query time frame in DQL .

I want to change this DQL&nbsp;fetch logs ,from:now() - 5d to use query timeframe from user interface

---

<div class="post-metadata">

**Author:** ![dani\_coll](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dani_coll/32/33669_2.png) [@dani\_coll](https://community.dynatrace.com/u/dani_coll)\
**Post date:** [September 23, 2025, 4:24pm UTC](https://community.dynatrace.com/t/use-controls-offered-by-the-user-interface-to-select-your-query-time-frame-in-dql/53464/2 "2025-09-23T16:24:50Z")

</div>

Hi Lejil,  
It’s possible to do that by using the _onChange_ callback from the [TimeframeSelector](https://developer.dynatrace.com/design/components-preview/filters/TimeframeSelector/usage/) component to dynamically modify your DQL query string.

Another solution, which in my opinion is simpler because you don’t need to modify the DQL query, is to set the&nbsp;_defaultTimeframeStart_ and&nbsp;_defaultTimeframeEnd_&nbsp;attributes on your [useDql](https://developer.dynatrace.com/develop/sdks/react-hooks/) hook instead of modifying the DQL query.

Here’s a full snippet of the solution

```javascript
import { useDql } from "@dynatrace-sdk/react-hooks";
import { TimeframeSelector } from "@dynatrace/strato-components-preview/forms";
import { TimeframeV2 } from "@dynatrace/strato-components-preview/core";
import { useState } from "react";
import React from "react";

export const App = () => { 
    const [timeframe, setTimeframe] = useState<TimeframeV2>({
        from: {
            absoluteDate: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString(),
            value: 'now()-5d',
            type: 'expression',
        },
        to: {
            absoluteDate: new Date().toISOString(),
            value: 'now()',
            type: 'expression',
        },
    });  

    const logsResult = useDql({
        query: 'fetch logs',
        defaultTimeframeStart: timeframe.from.absoluteDate,
        defaultTimeframeEnd: timeframe.to.absoluteDate,
    })

    return (
    <>
        <TimeframeSelector
            value={timeframe}
            onChange={(tf) => {if(tf) setTimeframe(tf)}}
            precision="seconds"
        />
    </>)
}

```
