<?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 how to sort date in header level in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673285#M230545</link>
    <description>&lt;P&gt;&lt;SPAN&gt;this query showing date &amp;amp;time&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;haphazardly, how to sort it like 1/4/2024, 1/3/2024, 1/2/2024....&lt;BR /&gt;&lt;BR /&gt;index="*" source="*" |eval&lt;BR /&gt;timestamp=strftime(_time, "%m/%d/%Y")&lt;BR /&gt;| chart limit=30&lt;BR /&gt;count as count&lt;BR /&gt;over DFOINTERFACE&lt;BR /&gt;by timestamp&lt;/SPAN&gt;&lt;/P&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="avikc100_0-1704408791144.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28772i4E703199ED44DC4A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="avikc100_0-1704408791144.png" alt="avikc100_0-1704408791144.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2024 22:54:16 GMT</pubDate>
    <dc:creator>avikc100</dc:creator>
    <dc:date>2024-01-04T22:54:16Z</dc:date>
    <item>
      <title>how to sort date in header level</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673285#M230545</link>
      <description>&lt;P&gt;&lt;SPAN&gt;this query showing date &amp;amp;time&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;haphazardly, how to sort it like 1/4/2024, 1/3/2024, 1/2/2024....&lt;BR /&gt;&lt;BR /&gt;index="*" source="*" |eval&lt;BR /&gt;timestamp=strftime(_time, "%m/%d/%Y")&lt;BR /&gt;| chart limit=30&lt;BR /&gt;count as count&lt;BR /&gt;over DFOINTERFACE&lt;BR /&gt;by timestamp&lt;/SPAN&gt;&lt;/P&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="avikc100_0-1704408791144.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28772i4E703199ED44DC4A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="avikc100_0-1704408791144.png" alt="avikc100_0-1704408791144.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 22:54:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673285#M230545</guid>
      <dc:creator>avikc100</dc:creator>
      <dc:date>2024-01-04T22:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort date in header level</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673288#M230546</link>
      <description>&lt;P&gt;There is no good way to sort column using mm/dd/yyyy format. &amp;nbsp;What's wrong with yyyy-mm-dd?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="*" source="*" |eval
timestamp=strftime(_time, "%F")
| chart limit=30
count as count
over DFOINTERFACE
by timestamp&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Jan 2024 23:21:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673288#M230546</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-01-04T23:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort date in header level</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673290#M230547</link>
      <description>&lt;P&gt;Something like this should sort your column in the intended order with the time format requested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&amp;lt;base_search&amp;gt;
    ``` bucket _time into each respective day ```
    | bucket span=1d _time
    ``` transform data in a normal Splunk friendly timeseries format ```
    | chart
        count as count
            over _time
            by DFOINTERFACE
    ``` ensure ascending order of _time field ```
    | sort 0 +_time
    ``` format timestamp as desired ```
    | eval
        timestamp=strftime(_time, "%m/%d/%Y")
    ``` remove _time field (no longer needed) ```
    | fields - _time
    ``` transpose table (this should retain the sort order of date ```
    ``` note: transpose has default limits on number of columns that will display. The 25 here is saying allow at the most 25 columns to be available before truncation occurs. ```
    | transpose 25 header_field=timestamp column_name=DFOINTERFACE&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704411303205.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28773i6B77BD68894C054A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704411303205.png" alt="dtburrows3_0-1704411303205.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is basically the same question that was asked here.&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/how-to-report-based-on-date/m-p/673054" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/how-to-report-based-on-date/m-p/673054&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 00:10:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673290#M230547</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-05T00:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort date in header level</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673293#M230549</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/235231"&gt;@avikc100&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically in Splunk the time and date operations should be done like this:&lt;/P&gt;&lt;P&gt;1) Splunk has an event's timestamp in some format (dd-mm-yy aa:bb:cc dddd).&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) convert that to epoch timestamp (use strptime)&lt;/P&gt;&lt;P&gt;-----&amp;nbsp;strptime(&amp;lt;str&amp;gt;, &amp;lt;format&amp;gt;)&lt;BR /&gt;------Takes a human readable time, represented by a string, and parses the time into a UNIX timestamp using the format you specify.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) then do sorting, comparison operations on the epoch timestamp.&lt;/P&gt;&lt;P&gt;4) and then convert back to human readable timestamp (use strftime)&lt;BR /&gt;------strftime(&amp;lt;time&amp;gt;,&amp;lt;format&amp;gt;)&lt;BR /&gt;------This function takes a UNIX time value and renders the time as a string using the format specified.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if any reply helped you, then, karma&amp;nbsp; / upvotes&amp;nbsp; appreciated, thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 00:51:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sort-date-in-header-level/m-p/673293#M230549</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2024-01-05T00:51:27Z</dc:date>
    </item>
  </channel>
</rss>

