<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic use controls offered by the user interface to select your query time frame in DQL in Developer Q&amp;A Forum</title>
    <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/use-controls-offered-by-the-user-interface-to-select-your-query/m-p/286638#M1546</link>
    <description>&lt;P&gt;How can I use controls offered by the user interface to select your query time frame in DQL .&lt;/P&gt;&lt;P&gt;I want to change this DQL&amp;nbsp;fetch logs ,from:now() - 5d to use query timeframe from user interface&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Sep 2025 15:32:19 GMT</pubDate>
    <dc:creator>Lejil</dc:creator>
    <dc:date>2025-09-23T15:32:19Z</dc:date>
    <item>
      <title>use controls offered by the user interface to select your query time frame in DQL</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/use-controls-offered-by-the-user-interface-to-select-your-query/m-p/286638#M1546</link>
      <description>&lt;P&gt;How can I use controls offered by the user interface to select your query time frame in DQL .&lt;/P&gt;&lt;P&gt;I want to change this DQL&amp;nbsp;fetch logs ,from:now() - 5d to use query timeframe from user interface&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 15:32:19 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/use-controls-offered-by-the-user-interface-to-select-your-query/m-p/286638#M1546</guid>
      <dc:creator>Lejil</dc:creator>
      <dc:date>2025-09-23T15:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: use controls offered by the user interface to select your query time frame in DQL</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/use-controls-offered-by-the-user-interface-to-select-your-query/m-p/286643#M1547</link>
      <description>&lt;P&gt;Hi Lejil,&lt;BR /&gt;It's possible to do that by using the &lt;EM&gt;onChange&lt;/EM&gt; callback from the &lt;A href="https://developer.dynatrace.com/design/components-preview/filters/TimeframeSelector/usage/" target="_self"&gt;TimeframeSelector&lt;/A&gt; component to dynamically modify your DQL query string. &lt;BR /&gt;&lt;BR /&gt;Another solution, which in my opinion is simpler because you don't need to modify the DQL query, is to set the&amp;nbsp;&lt;SPAN&gt;&lt;SPAN&gt;&lt;EM&gt;defaultTimeframeStart&lt;/EM&gt; and&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;EM&gt;defaultTimeframeEnd&lt;/EM&gt;&amp;nbsp;attributes on your &lt;A href="https://developer.dynatrace.com/develop/sdks/react-hooks/" target="_self"&gt;useDql&lt;/A&gt; hook instead of modifying the DQL query.&lt;BR /&gt;&lt;BR /&gt;Here's a full snippet of the solution&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;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 = () =&amp;gt; { 
    const [timeframe, setTimeframe] = useState&amp;lt;TimeframeV2&amp;gt;({
        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 (
    &amp;lt;&amp;gt;
        &amp;lt;TimeframeSelector
            value={timeframe}
            onChange={(tf) =&amp;gt; {if(tf) setTimeframe(tf)}}
            precision="seconds"
        /&amp;gt;
    &amp;lt;/&amp;gt;)
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 16:27:15 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/use-controls-offered-by-the-user-interface-to-select-your-query/m-p/286643#M1547</guid>
      <dc:creator>dani_coll</dc:creator>
      <dc:date>2025-09-23T16:27:15Z</dc:date>
    </item>
  </channel>
</rss>

