<?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: How to sort using formatted time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-using-formatted-time/m-p/370776#M162089</link>
    <description>&lt;P&gt;My recommendation is to not convert the &lt;CODE&gt;_time&lt;/CODE&gt; field with an eval but instead to use the command &lt;CODE&gt;fieldformat&lt;/CODE&gt; to change how the value is displayed while retaining the original epoch string, which is easily sortable. That search would look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search that filters down to events in the desired time range
| bucket _time span=1h 
| stats count(id) as "Unsuccessful Logins" by _time
| sort _time 
| fieldformat _time=strftime(_time, "%b %d, %Y %I:%M:%S %p") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Mar 2018 18:12:41 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2018-03-21T18:12:41Z</dc:date>
    <item>
      <title>How to sort using formatted time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-using-formatted-time/m-p/370775#M162088</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a result table with two columns "formattedTime" and "Unsuccessful logins". I am displaying time in the format like " eval formattedTime = strftime(_time, "%b %d, %Y %I:%M:%S %p") ". I see the following result in the output:&lt;/P&gt;

&lt;P&gt;formattedTime   Unsuccessful Logins&lt;BR /&gt;
Mar 20, 2018 01:00:00 AM    1799&lt;BR /&gt;
Mar 20, 2018 01:00:00 PM    3741&lt;BR /&gt;
Mar 20, 2018 02:00:00 AM    1785&lt;BR /&gt;
Mar 20, 2018 02:00:00 PM    3703&lt;BR /&gt;
Mar 20, 2018 03:00:00 AM    1694&lt;BR /&gt;
Mar 20, 2018 03:00:00 PM    3651&lt;BR /&gt;
Mar 20, 2018 04:00:00 AM    1764&lt;BR /&gt;
Mar 20, 2018 04:00:00 PM    3683&lt;BR /&gt;
Mar 20, 2018 05:00:00 AM    2515&lt;/P&gt;

&lt;P&gt;What I need is to display the results from 12 AM - 4 PM is ascending format.&lt;/P&gt;

&lt;P&gt;This is the current logic I am using to display those results: &lt;/P&gt;

&lt;P&gt;| bucket _time span=1h | eval formattedTime = strftime(_time, "%b %d, %Y %I:%M:%S %p") |stats count(id) as "Unsuccessful Logins" by formattedTime| sort formattedTime&lt;/P&gt;

&lt;P&gt;Any one please help me!&lt;/P&gt;

&lt;P&gt;Thanks in advance. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:37:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-using-formatted-time/m-p/370775#M162088</guid>
      <dc:creator>rakeshyv0807</dc:creator>
      <dc:date>2020-09-29T18:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort using formatted time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-using-formatted-time/m-p/370776#M162089</link>
      <description>&lt;P&gt;My recommendation is to not convert the &lt;CODE&gt;_time&lt;/CODE&gt; field with an eval but instead to use the command &lt;CODE&gt;fieldformat&lt;/CODE&gt; to change how the value is displayed while retaining the original epoch string, which is easily sortable. That search would look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search that filters down to events in the desired time range
| bucket _time span=1h 
| stats count(id) as "Unsuccessful Logins" by _time
| sort _time 
| fieldformat _time=strftime(_time, "%b %d, %Y %I:%M:%S %p") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Mar 2018 18:12:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-using-formatted-time/m-p/370776#M162089</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-21T18:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort using formatted time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-using-formatted-time/m-p/370777#M162090</link>
      <description>&lt;P&gt;@elliotproebstel - Thank you for the suggestion. It worked as expected.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 19:57:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-using-formatted-time/m-p/370777#M162090</guid>
      <dc:creator>rakeshyv0807</dc:creator>
      <dc:date>2018-03-21T19:57:29Z</dc:date>
    </item>
  </channel>
</rss>

