<?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: date format in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/date-format/m-p/276979#M2056</link>
    <description>&lt;P&gt;If we assume that your logs already have a timestamp, then there are threesteps to take here:&lt;/P&gt;&lt;P&gt;Step 1:&lt;/P&gt;&lt;P&gt;Just before your summarize command, use the&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/functions/time-functions#formatTimestamp" target="_self"&gt;formatTimestamp&lt;/A&gt; function to extract just the calendar date from the existing timestamp field into a new field called 'date', as seen in the example below.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| fieldsAdd date = formatTimestamp(timestamp, format:"MM-dd-yyyy")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 2:&lt;/P&gt;&lt;P&gt;Amend your summarize command to summarize your the data by status and also date.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| summarize {ngssdublin = countIf(market == "ngssdublin"),
ngssmilan = countIf(market == "ngssmilan"),
ngssrat = countIf(market == "ngssrat")}, 
by:{Status, date}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 3:&amp;nbsp;&lt;/P&gt;&lt;P&gt;To calculate the total column, use the fieldsAdd command at the end of your query (after the summarize command) to calculate the new field, as seen below.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| fieldsAdd total = ngssdublin + gssmilan + ngssrat	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 May 2025 21:50:35 GMT</pubDate>
    <dc:creator>marco_irmer</dc:creator>
    <dc:date>2025-05-12T21:50:35Z</dc:date>
    <item>
      <title>date format</title>
      <link>https://community.dynatrace.com/t5/DQL/date-format/m-p/276932#M2051</link>
      <description>&lt;P&gt;&lt;SPAN&gt;In the query below, I want to add a new column that displays only the date (MM-DD-YYYY) of the ingested logs data. Additionally, I want to include another column named "total" that will show the combined count of Blocked and Detected logs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;below is the format of required data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE width="409"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="85"&gt;Local_Market&lt;/TD&gt;
&lt;TD width="65"&gt;Total&lt;/TD&gt;
&lt;TD width="69"&gt;ngssdublin&lt;/TD&gt;
&lt;TD width="66"&gt;ngssmilan&lt;/TD&gt;
&lt;TD width="57"&gt;ngssrat&lt;/TD&gt;
&lt;TD width="67"&gt;date&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Blocked&lt;/TD&gt;
&lt;TD&gt;12262651&lt;/TD&gt;
&lt;TD&gt;450273&lt;/TD&gt;
&lt;TD&gt;4648609&lt;/TD&gt;
&lt;TD&gt;7163769&lt;/TD&gt;
&lt;TD&gt;11/5/2025&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Detected&lt;/TD&gt;
&lt;TD&gt;3893652&lt;/TD&gt;
&lt;TD&gt;4266&lt;/TD&gt;
&lt;TD&gt;3887955&lt;/TD&gt;
&lt;TD&gt;1431&lt;/TD&gt;
&lt;TD&gt;11/5/2025&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is the query ..&lt;/P&gt;
&lt;P&gt;fetch logs // scanLimitGBytes: , samplingRatio: 1000&lt;BR /&gt;| filter contains(dt.security_context, "ngss")&lt;BR /&gt;//| fieldsAdd a=matchesValue(index,"*ngss")&lt;BR /&gt;//| filter a=="true"&lt;BR /&gt;| fieldsAdd content2 = concat(content, "}")&lt;BR /&gt;| parse content2, "JSON:data"&lt;BR /&gt;| fieldsAdd InlineResultID = data[`InlineResultID`]&lt;BR /&gt;| fieldsAdd Status = if(InlineResultID == 0, "Detected", else:&lt;BR /&gt;if(InlineResultID !=0 AND InlineResultID != 2, "Blocked", else:"Blocked"))&lt;BR /&gt;| filterOut InlineResultID == 2&lt;BR /&gt;| fieldsAdd market = substring(dt.security_context, to: indexOf(dt.security_context, "_"))&lt;BR /&gt;// | fieldsAdd market = if(contains(market, "cita"), substring(market, from:4), else:market)&lt;BR /&gt;| fieldsAdd market = replaceString(market, "cita", "")&lt;BR /&gt;&lt;BR /&gt;| summarize {ngssdublin = countIf(market == "ngssdublin"),&lt;BR /&gt;ngssmilan = countIf(market == "ngssmilan"),&lt;BR /&gt;ngssrat = countIf(market == "ngssrat")}, by:{Status}&lt;/P&gt;
&lt;P&gt;//| fieldsadd timestamp('yyyy-MM-dd),timezone:'UTC'):datetime&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2025 06:32:29 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/date-format/m-p/276932#M2051</guid>
      <dc:creator>sharmas2</dc:creator>
      <dc:date>2025-05-13T06:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: date format</title>
      <link>https://community.dynatrace.com/t5/DQL/date-format/m-p/276979#M2056</link>
      <description>&lt;P&gt;If we assume that your logs already have a timestamp, then there are threesteps to take here:&lt;/P&gt;&lt;P&gt;Step 1:&lt;/P&gt;&lt;P&gt;Just before your summarize command, use the&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/functions/time-functions#formatTimestamp" target="_self"&gt;formatTimestamp&lt;/A&gt; function to extract just the calendar date from the existing timestamp field into a new field called 'date', as seen in the example below.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| fieldsAdd date = formatTimestamp(timestamp, format:"MM-dd-yyyy")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 2:&lt;/P&gt;&lt;P&gt;Amend your summarize command to summarize your the data by status and also date.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| summarize {ngssdublin = countIf(market == "ngssdublin"),
ngssmilan = countIf(market == "ngssmilan"),
ngssrat = countIf(market == "ngssrat")}, 
by:{Status, date}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 3:&amp;nbsp;&lt;/P&gt;&lt;P&gt;To calculate the total column, use the fieldsAdd command at the end of your query (after the summarize command) to calculate the new field, as seen below.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| fieldsAdd total = ngssdublin + gssmilan + ngssrat	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 May 2025 21:50:35 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/date-format/m-p/276979#M2056</guid>
      <dc:creator>marco_irmer</dc:creator>
      <dc:date>2025-05-12T21:50:35Z</dc:date>
    </item>
  </channel>
</rss>

