<?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 Re: Using Timeframe Selector as an input for a DQL query in Developer Q&amp;A Forum</title>
    <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206685#M216</link>
    <description>&lt;P&gt;The &lt;EM&gt;from&lt;/EM&gt; and &lt;EM&gt;to&lt;/EM&gt; inside of&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;TimeframeDetails&lt;/EM&gt; are of the type &lt;EM&gt;TimeDetails&lt;/EM&gt;. You need to call the parser for both, the from and the to.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 15:52:37 GMT</pubDate>
    <dc:creator>Wolfi-Stefan</dc:creator>
    <dc:date>2023-03-09T15:52:37Z</dc:date>
    <item>
      <title>Using Timeframe Selector as an input for a DQL query</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206615#M211</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I'm trying to use a Timeframe Selector (&lt;A href="https://developer.dynatrace.com/reference/design-system/preview/forms/TimeframeSelector/" target="_blank" rel="noopener"&gt;https://developer.dynatrace.com/reference/design-system/preview/forms/TimeframeSelector/&lt;/A&gt;) for user input for my DQL query. It's not working as the output of the selector is not compatible with DQL.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Specifically, this is the o&lt;/SPAN&gt;utput of &lt;EM&gt;timeframe.from&lt;/EM&gt; and &lt;EM&gt;timeframe.to:&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3ene_0-1678350471031.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/10389i0B2739C178AC1965/image-size/medium?v=v2&amp;amp;px=400" role="button" title="3ene_0-1678350471031.png" alt="3ene_0-1678350471031.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The DQL editor complains about that because 'now' is a dynamic variable, and DQL queries only work with static ones. Ergo, only &lt;EM&gt;now()&lt;/EM&gt;&amp;nbsp;would work.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can someone tell me how to do the conversion properly?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 13:18:02 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206615#M211</guid>
      <dc:creator>3ene</dc:creator>
      <dc:date>2023-05-02T13:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timeframe Selector as an input for a DQL query</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206620#M212</link>
      <description>&lt;P&gt;Hi!&lt;BR /&gt;&lt;BR /&gt;The onChange event returns the actual timestamp values as well, which you can use in your DQL Queries:&lt;BR /&gt;&lt;A href="https://developer.dynatrace.com/reference/design-system/preview/forms/TimeframeSelector/#get-timeframe-details" target="_blank" rel="noopener"&gt;https://developer.dynatrace.com/reference/design-system/preview/forms/TimeframeSelector/#get-timeframe-details&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;onChange={(timeframe) =&amp;gt; {
   setValue(timeframe);
   setTimeframeDetails(timeframe?.details ?? null);
}}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 13:18:47 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206620#M212</guid>
      <dc:creator>Wolfi-Stefan</dc:creator>
      <dc:date>2023-05-02T13:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timeframe Selector as an input for a DQL query</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206624#M213</link>
      <description>&lt;P&gt;Hi Stefan,&lt;/P&gt;
&lt;P&gt;that's cool, but I now run into a different issue: How do I default set TimeframeDetails to now()?&lt;/P&gt;
&lt;P&gt;I'd like to run a query immediately on app start and therefore need to have TimeframeDetails already set to now. Is there a way to translate between Timeframe and TimeframeDetails?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 09:43:54 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206624#M213</guid>
      <dc:creator>3ene</dc:creator>
      <dc:date>2023-03-09T09:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timeframe Selector as an input for a DQL query</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206633#M214</link>
      <description>&lt;P&gt;You can use the parseTime function, which is also used by the TimeframeSelector internally:&amp;nbsp;&lt;A href="https://developer.dynatrace.com/reference/design-system/preview/core/utils/parseTime/" target="_blank" rel="noopener"&gt;https://developer.dynatrace.com/reference/design-system/preview/core/utils/parseTime/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The function returns the T&lt;SPAN&gt;imeDetails type.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 13:19:14 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206633#M214</guid>
      <dc:creator>Wolfi-Stefan</dc:creator>
      <dc:date>2023-05-02T13:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timeframe Selector as an input for a DQL query</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206675#M215</link>
      <description>&lt;P&gt;I just tried it out and unfortunately it doesn't work as parseTime returns a TimeDetails and not a TimeframeDetails object. Can you tell me how to create a TimeframeDetails obj?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3ene_0-1678373899659.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/10408i0A18448487BDCAA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="3ene_0-1678373899659.png" alt="3ene_0-1678373899659.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 14:59:15 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206675#M215</guid>
      <dc:creator>3ene</dc:creator>
      <dc:date>2023-03-09T14:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timeframe Selector as an input for a DQL query</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206685#M216</link>
      <description>&lt;P&gt;The &lt;EM&gt;from&lt;/EM&gt; and &lt;EM&gt;to&lt;/EM&gt; inside of&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;TimeframeDetails&lt;/EM&gt; are of the type &lt;EM&gt;TimeDetails&lt;/EM&gt;. You need to call the parser for both, the from and the to.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 15:52:37 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206685#M216</guid>
      <dc:creator>Wolfi-Stefan</dc:creator>
      <dc:date>2023-03-09T15:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timeframe Selector as an input for a DQL query</title>
      <link>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206795#M219</link>
      <description>&lt;P&gt;There were a couple more bumps in the road, so I want to share my final solution to my problem here. Please note that for my app, I needed to initialize the values of the Timeframe and TimeframeDetail variables upon opening the app, which makes this a little more difficult. I do it with following 2 lines:&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;timeframe&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;setTimeframe&lt;/SPAN&gt;&lt;SPAN&gt;] = &lt;/SPAN&gt;&lt;SPAN&gt;React&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;useState&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;Timeframe&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;({&lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;'now-7d'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;'now'&lt;/SPAN&gt;&lt;SPAN&gt;});&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;timeframeDetails&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;setTimeframeDetails&lt;/SPAN&gt;&lt;SPAN&gt;] = &lt;/SPAN&gt;&lt;SPAN&gt;React&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;useState&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;TimeframeDetails&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;({&lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;parseTime&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'now-7d'&lt;/SPAN&gt;&lt;SPAN&gt;)!, &lt;/SPAN&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;parseTime&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'now'&lt;/SPAN&gt;&lt;SPAN&gt;)!});&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;Parsing it into DQL works like this for me:&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;queryBase&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;string&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;'fetch events, from: '&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;stringify&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;timeframeDetails&lt;/SPAN&gt;&lt;SPAN&gt;?.&lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;date&lt;/SPAN&gt;&lt;SPAN&gt;)+&lt;/SPAN&gt;&lt;SPAN&gt;', to:'&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;stringify&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;timeframeDetails&lt;/SPAN&gt;&lt;SPAN&gt;?.&lt;/SPAN&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;date&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;This results in following DQL:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;fetch events,&amp;nbsp;&lt;/SPAN&gt;from: "2023-03-03T15:01:18.390Z", to:"2023-03-10T15:01:18.390Z" [...]&lt;/PRE&gt;
&lt;P&gt;Thanks, Stefan for helping me figure this out!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 Mar 2023 15:02:55 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Developer-Q-A-Forum/Using-Timeframe-Selector-as-an-input-for-a-DQL-query/m-p/206795#M219</guid>
      <dc:creator>3ene</dc:creator>
      <dc:date>2023-03-10T15:02:55Z</dc:date>
    </item>
  </channel>
</rss>

