<?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 Time format and table sorting issues in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321509#M96062</link>
    <description>&lt;P&gt;So, I have this search on events that cover from  the 28th of February  to the 6th of March, 2018:&lt;/P&gt;

&lt;P&gt;&lt;PRE&gt;Some basic search&lt;BR /&gt;
    | eval customer_id = substr(host,2,5)&lt;BR /&gt;
    | eval session_duration = stop_time - start_time&lt;BR /&gt;
    | eval start_date = strftime(start_time,"%d/%m/%y %H:%M:%S")&lt;BR /&gt;
    | convert rmunit(session_duration) as numSecs&lt;BR /&gt;
    | eval stringSecs=tostring(numSecs,"duration")&lt;BR /&gt;
    | table customer_id,  start_date,  task_id,  host_ip, from_user, stringSecs &lt;BR /&gt;
    | sort by start_time d&lt;BR /&gt;
    | rename customer_id as "Customer ID", start_date as "Session Start", task_id as "Task id", host_ip as "Accessed Host", from_user as "User ID", stringSecs as "Session Duration"  &lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Which is creating the perfect "starting" table I want, with the more recent data at the top, up until I click on the table header to modify the date.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Ascending:&lt;/STRONG&gt;  (expecting 28/02/18)&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/230639-splunk-date1.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Descending:&lt;/STRONG&gt; (expecting 06/03/18) &lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/230640-splunk-date2.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;From what I understand, even if I specified the European time format in the search, the interactive table sorting is based on alphanumerical order.&lt;/P&gt;

&lt;P&gt;One quick fix would be to use the ISO format (YYYY-MM-DD) (for which I am opting right now), but what if the end user want absolutely to have dd/mm/yy and be able to click on the header to change the order?&lt;BR /&gt;
Is there an option to change this behavior?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 18:15:23 GMT</pubDate>
    <dc:creator>jwillaime</dc:creator>
    <dc:date>2020-09-29T18:15:23Z</dc:date>
    <item>
      <title>Time format and table sorting issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321509#M96062</link>
      <description>&lt;P&gt;So, I have this search on events that cover from  the 28th of February  to the 6th of March, 2018:&lt;/P&gt;

&lt;P&gt;&lt;PRE&gt;Some basic search&lt;BR /&gt;
    | eval customer_id = substr(host,2,5)&lt;BR /&gt;
    | eval session_duration = stop_time - start_time&lt;BR /&gt;
    | eval start_date = strftime(start_time,"%d/%m/%y %H:%M:%S")&lt;BR /&gt;
    | convert rmunit(session_duration) as numSecs&lt;BR /&gt;
    | eval stringSecs=tostring(numSecs,"duration")&lt;BR /&gt;
    | table customer_id,  start_date,  task_id,  host_ip, from_user, stringSecs &lt;BR /&gt;
    | sort by start_time d&lt;BR /&gt;
    | rename customer_id as "Customer ID", start_date as "Session Start", task_id as "Task id", host_ip as "Accessed Host", from_user as "User ID", stringSecs as "Session Duration"  &lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Which is creating the perfect "starting" table I want, with the more recent data at the top, up until I click on the table header to modify the date.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Ascending:&lt;/STRONG&gt;  (expecting 28/02/18)&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/230639-splunk-date1.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Descending:&lt;/STRONG&gt; (expecting 06/03/18) &lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/230640-splunk-date2.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;From what I understand, even if I specified the European time format in the search, the interactive table sorting is based on alphanumerical order.&lt;/P&gt;

&lt;P&gt;One quick fix would be to use the ISO format (YYYY-MM-DD) (for which I am opting right now), but what if the end user want absolutely to have dd/mm/yy and be able to click on the header to change the order?&lt;BR /&gt;
Is there an option to change this behavior?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321509#M96062</guid>
      <dc:creator>jwillaime</dc:creator>
      <dc:date>2020-09-29T18:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Time format and table sorting issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321510#M96063</link>
      <description>&lt;P&gt;okay if &lt;CODE&gt;YYYY-MM-DD&lt;/CODE&gt; format is fixing your issue then do that and if the  end user want absolutely to have &lt;CODE&gt;dd/mm/yy&lt;/CODE&gt; then you can try converting the time format after the sort &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Some basic search 
| eval customer_id = substr(host,2,5) 
| eval session_duration = stop_time - start_time 
| eval start_date = strftime(start_time,"%Y-%m-%d %H:%M:%S") 
| convert rmunit(session_duration) as numSecs 
| eval stringSecs=tostring(numSecs,"duration") 
| table customer_id, start_date, task_id, host_ip, from_user, stringSecs 
| sort by start_date 
| eval start_date=strftime(strptime(start_date,"%Y-%m-%d %H:%M:%S"),"%d/%m/%y %H:%M:%S") 
| rename customer_id as "Customer ID", start_date as "Session Start", task_id as "Task id", host_ip as "Accessed Host", from_user as "User ID", stringSecs as "Session Duration"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;BR /&gt;
You can use another method (bit complex but useful ) in which you need to sort date year month individually along with the entire time format and then remove unnecessary fields .&lt;BR /&gt;
Refer this answer&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/624327/how-to-arrange-by-monthyear-chronological-order.html#comment-624330"&gt;https://answers.splunk.com/answers/624327/how-to-arrange-by-monthyear-chronological-order.html#comment-624330&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 13:45:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321510#M96063</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-03-07T13:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Time format and table sorting issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321511#M96064</link>
      <description>&lt;P&gt;I would say to sort them first by and then do the eval to change the format.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 16:28:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321511#M96064</guid>
      <dc:creator>kollachandra</dc:creator>
      <dc:date>2018-03-07T16:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Time format and table sorting issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321512#M96065</link>
      <description>&lt;P&gt;Your first proposition has the same unwanted behavior. I'll take a look to the link you shared.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 07:48:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-format-and-table-sorting-issues/m-p/321512#M96065</guid>
      <dc:creator>jwillaime</dc:creator>
      <dc:date>2018-03-08T07:48:43Z</dc:date>
    </item>
  </channel>
</rss>

