<?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 Define business hours in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/213669#M8</link>
    <description>&lt;P&gt;Hi Team,&amp;nbsp;&lt;/P&gt;
&lt;DIV class="c-message_kit__blocks c-message_kit__blocks--rich_text"&gt;
&lt;DIV class="c-message__message_blocks c-message__message_blocks--rich_text" data-qa="message-text"&gt;
&lt;DIV class="p-block_kit_renderer" data-qa="block-kit-renderer"&gt;
&lt;DIV class="p-block_kit_renderer__block_wrapper p-block_kit_renderer__block_wrapper--first"&gt;
&lt;DIV class="p-rich_text_block" dir="auto"&gt;
&lt;DIV class="p-rich_text_section"&gt;how could I define business hours with DQL? I looked at filtering on the timestamp but can't really find a way. For example: for monday to friday, 08am to 7pm.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="c-message_kit__reaction_bar c-reaction_bar c-reaction_bar--light c-reaction_bar--collapsed" role="group" data-qa="reaction_bar" aria-label="Reactions" data-stringify-ignore="true"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="c-message_kit__reaction_bar c-reaction_bar c-reaction_bar--light c-reaction_bar--collapsed" role="group" data-qa="reaction_bar" aria-label="Reactions" data-stringify-ignore="true"&gt;Best,&lt;BR /&gt;Sini&lt;/DIV&gt;</description>
    <pubDate>Wed, 31 May 2023 14:02:17 GMT</pubDate>
    <dc:creator>sinisa_zubic</dc:creator>
    <dc:date>2023-05-31T14:02:17Z</dc:date>
    <item>
      <title>Define business hours</title>
      <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/213669#M8</link>
      <description>&lt;P&gt;Hi Team,&amp;nbsp;&lt;/P&gt;
&lt;DIV class="c-message_kit__blocks c-message_kit__blocks--rich_text"&gt;
&lt;DIV class="c-message__message_blocks c-message__message_blocks--rich_text" data-qa="message-text"&gt;
&lt;DIV class="p-block_kit_renderer" data-qa="block-kit-renderer"&gt;
&lt;DIV class="p-block_kit_renderer__block_wrapper p-block_kit_renderer__block_wrapper--first"&gt;
&lt;DIV class="p-rich_text_block" dir="auto"&gt;
&lt;DIV class="p-rich_text_section"&gt;how could I define business hours with DQL? I looked at filtering on the timestamp but can't really find a way. For example: for monday to friday, 08am to 7pm.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="c-message_kit__reaction_bar c-reaction_bar c-reaction_bar--light c-reaction_bar--collapsed" role="group" data-qa="reaction_bar" aria-label="Reactions" data-stringify-ignore="true"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="c-message_kit__reaction_bar c-reaction_bar c-reaction_bar--light c-reaction_bar--collapsed" role="group" data-qa="reaction_bar" aria-label="Reactions" data-stringify-ignore="true"&gt;Best,&lt;BR /&gt;Sini&lt;/DIV&gt;</description>
      <pubDate>Wed, 31 May 2023 14:02:17 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/213669#M8</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-05-31T14:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Define business hours</title>
      <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/213762#M22</link>
      <description>&lt;P&gt;Hi Sinisa, the Notebooks app has a snippet for this use case:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-06-01 at 8.37.21 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/12018i240D245AFB651D6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-06-01 at 8.37.21 AM.png" alt="Screenshot 2023-06-01 at 8.37.21 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here's the query anyways:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch bizevents, from:now()-7d, to:now()
| fieldsAdd hour=toLong(formatTimestamp(timestamp,format:"H")), day_of_week = formatTimestamp(timestamp,format:"EE")
| filterOut day_of_week == "Sat" or day_of_week == "Sun" // Remove weekend days
| filterOut hour &amp;lt;= 5 or hour &amp;gt;= 15 // Remove everything that is not between 5am and 3pm&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 14:55:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/213762#M22</guid>
      <dc:creator>educampver</dc:creator>
      <dc:date>2023-06-01T14:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Define business hours</title>
      <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292495#M3001</link>
      <description>&lt;P&gt;How would you do this using the timeseries command (using metrics)?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2026 16:41:18 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292495#M3001</guid>
      <dc:creator>gdalessandro</dc:creator>
      <dc:date>2026-01-06T16:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Define business hours</title>
      <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292704#M3012</link>
      <description>&lt;P&gt;I would suggest to use&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;getHour()&lt;/EM&gt; &lt;/STRONG&gt;and &lt;EM&gt;&lt;STRONG&gt;getDayOfWeek()&lt;/STRONG&gt;&lt;/EM&gt; functions instead of &lt;EM&gt;&lt;STRONG&gt;formatTimestamp()&lt;/STRONG&gt;&lt;/EM&gt; and conversion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2026 18:04:39 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292704#M3012</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2026-01-08T18:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Define business hours</title>
      <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292706#M3013</link>
      <description>&lt;P&gt;For timeseries you can also use&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;getHour()&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;and&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;getDayOfWeek()&lt;/STRONG&gt;&lt;/EM&gt; functions, but you need first timestamps of particular buckets using &lt;EM&gt;&lt;STRONG&gt;start()&lt;/STRONG&gt;&lt;/EM&gt; funtion, so you can filter out irrelevant values:&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries {d=avg(dt.host.cpu.usage), timestamp=start()}, interval:1h
| fieldsAdd d = if(getHour(timestamp[])&amp;gt;=7 and getHour(timestamp[])&amp;lt;=16 and not in(getDayOfWeek(timestamp[]), {6,7}) , d[])
| fieldsRemove timestamp&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1767896117650.png" style="width: 823px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/31479i041F021D845F41A3/image-dimensions/823x358?v=v2" width="823" height="358" role="button" title="krzysztof_hoja_0-1767896117650.png" alt="krzysztof_hoja_0-1767896117650.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2026 18:15:47 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292706#M3013</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2026-01-08T18:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Define business hours</title>
      <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292754#M3019</link>
      <description>&lt;P&gt;While this works for "common cases", it's much more difficult to implement a calendar-based business hours considering, for example, holidays during working days or other events.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;One approach I still use with customers is a "calendar metric" representing business availability and then you can use it in the DQL to filter by multiplication.&lt;BR /&gt;&lt;BR /&gt;See details of it in this &lt;A href="https://community.dynatrace.com/t5/Custom-Solutions-Spotlight/PRO-TIP-Business-hours-in-Dynatrace-for-SLOs-or-metric-events/m-p/240367#M153" target="_blank"&gt;post&lt;/A&gt;&amp;nbsp;. Even though this was originally developed for classic metrics for SLO calculation purposes, it can be used with DQL / Grail in the very same way.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2026 11:59:27 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292754#M3019</guid>
      <dc:creator>Julius_Loman</dc:creator>
      <dc:date>2026-01-09T11:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Define business hours</title>
      <link>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292756#M3020</link>
      <description>&lt;P&gt;Yes, if you have fact of being in or out of business hours ingested in Grail as indpendent timeseries, you can use it to filter any other timeseries with data,&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2026 12:19:50 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Define-business-hours/m-p/292756#M3020</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2026-01-09T12:19:50Z</dc:date>
    </item>
  </channel>
</rss>

