<?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 order chronologically when _time has been evaluated with strftime? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465351#M131097</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;
 I know that. The thing is, when  I sort by "Last seen", splunk does not recognize the field as a date field. So it sort it numerically as text string, then it does not respect the date order.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Dec 2019 17:13:37 GMT</pubDate>
    <dc:creator>3DGjos</dc:creator>
    <dc:date>2019-12-12T17:13:37Z</dc:date>
    <item>
      <title>How to order chronologically when _time has been evaluated with strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465348#M131094</link>
      <description>&lt;P&gt;Hello, I always have problems ordering my events after evaluating _time to something else. See this query for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| mybasesearch
| eval "Last seen"=strftime(_time, "%d/%m/%Y %H:%M") 
| morequerytablestuff
| sort - _time
| fields - _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here I had to keep _time in my table, sort the events, and then remove the _time field from it.&lt;/P&gt;

&lt;P&gt;Is there a better way of achieving this?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465348#M131094</guid>
      <dc:creator>3DGjos</dc:creator>
      <dc:date>2019-12-12T16:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to order chronologically when _time has been evaluated with strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465349#M131095</link>
      <description>&lt;P&gt;Hi @3DGjos,&lt;BR /&gt;
your search seems to be correct, only one thing: don't use space between - and _time (that instead you have to use in fields command), so use something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mybasesearch
| eval "Last seen"=strftime(_time, "%d/%m/%Y %H:%M") 
| morequerytablestuff
| sort -_time
| fields - _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I have two questions:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;at the end of your basesearch (I think that you're speaking of Post Process Search), did you used the command fields with all the fields you need in panels' searches including _time?&lt;/LI&gt;
&lt;LI&gt;in morequerytablestuff have you some stats or chart or timechart commands? if yes, remember that after you can use ony the fields that are in the command.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:42:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465349#M131095</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-12T16:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to order chronologically when _time has been evaluated with strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465350#M131096</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;you have to use "Last seen"  for rest of your query and you are evaluating and assigning _time value to this variable&lt;/P&gt;

&lt;P&gt;give &lt;CODE&gt;|sort  - "Last seen" | fields - "Last seen"&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Thanks &lt;BR /&gt;
Anantha.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 16:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465350#M131096</guid>
      <dc:creator>Anantha123</dc:creator>
      <dc:date>2019-12-12T16:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to order chronologically when _time has been evaluated with strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465351#M131097</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
 I know that. The thing is, when  I sort by "Last seen", splunk does not recognize the field as a date field. So it sort it numerically as text string, then it does not respect the date order.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 17:13:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465351#M131097</guid>
      <dc:creator>3DGjos</dc:creator>
      <dc:date>2019-12-12T17:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to order chronologically when _time has been evaluated with strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465352#M131098</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
 yes i'm passing the _time values in my stats command, and passed all the fields from the base search.&lt;/P&gt;

&lt;P&gt;the problem is, that splunk does not recognize the  "last seen" field as a date field.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 17:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465352#M131098</guid>
      <dc:creator>3DGjos</dc:creator>
      <dc:date>2019-12-12T17:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to order chronologically when _time has been evaluated with strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465353#M131099</link>
      <description>&lt;P&gt;Hi @3DGjos,&lt;BR /&gt;
infact "last seen" field is a string that is sorted as a string in alphabetical order, for this reason it's correct to sort for _time.&lt;/P&gt;

&lt;P&gt;Yoy eventually could change the order of the statements:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; mybasesearch
 | morequerytablestuff
 | sort -_time
 | reame _time AS "Last seen"
 | eval "Last seen"=strftime("Last seen", "%d/%m/%Y %H:%M") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but this solution isn't so different from your one.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 17:31:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465353#M131099</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-12T17:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to order chronologically when _time has been evaluated with strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465354#M131100</link>
      <description>&lt;P&gt;Don't do it that way, use &lt;CODE&gt;fieldformat&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mybasesearch
| rename _time AS "Last seen"
| fieldformat  "Last seen"=strftime('Last seen', "%d/%m/%Y %H:%M") 
| morequerytablestuff
| sort 0 - "Last seen"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 00:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-order-chronologically-when-time-has-been-evaluated-with/m-p/465354#M131100</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-13T00:18:19Z</dc:date>
    </item>
  </channel>
</rss>

