<?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: Splunk not sorting Dates properly across year in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482695#M135201</link>
    <description>&lt;P&gt;It is sorting correctly based upon the lexicographic ordering.&lt;/P&gt;

&lt;P&gt;If you want to sort by a section of the string, in this case the year, then you have a couple options:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Change the format of your field values so that the year is first. For example, 2019-06-16 will come before 2020-01-12. You can use something like &lt;CODE&gt;| eval Time=strftime(your_field,"%Y-%m-%d")&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Keep the current field format as-is, create a sorting field called something like dateSort which has the format in the previous item, sort by that, then remove the dateSort field.&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Mon, 13 Jan 2020 19:35:11 GMT</pubDate>
    <dc:creator>jpolvino</dc:creator>
    <dc:date>2020-01-13T19:35:11Z</dc:date>
    <item>
      <title>Splunk not sorting Dates properly across year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482694#M135200</link>
      <description>&lt;P&gt;1/5/2020&lt;BR /&gt;
1/12/2020&lt;BR /&gt;
6/16/2019&lt;BR /&gt;
6/23/2019&lt;BR /&gt;
6/30/2019&lt;BR /&gt;
7/7/2019&lt;BR /&gt;
7/14/2019&lt;BR /&gt;
7/21/2019&lt;BR /&gt;
7/28/2019&lt;BR /&gt;
8/4/2019&lt;BR /&gt;
8/11/2019&lt;BR /&gt;
8/18/2019&lt;BR /&gt;
8/25/2019&lt;BR /&gt;
9/1/2019&lt;BR /&gt;
9/8/2019&lt;BR /&gt;
9/15/2019&lt;BR /&gt;
9/22/2019&lt;BR /&gt;
9/29/2019&lt;BR /&gt;
10/6/2019&lt;BR /&gt;
10/13/2019&lt;BR /&gt;
10/20/2019&lt;BR /&gt;
10/27/2019&lt;BR /&gt;
11/3/2019&lt;BR /&gt;
11/10/2019&lt;BR /&gt;
11/17/2019&lt;BR /&gt;
11/24/2019&lt;BR /&gt;
12/1/2019&lt;BR /&gt;
12/8/2019&lt;BR /&gt;
12/15/2019&lt;BR /&gt;
12/22/2019&lt;BR /&gt;
12/29/2019&lt;/P&gt;

&lt;P&gt;Any solution ?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 18:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482694#M135200</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2020-01-13T18:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk not sorting Dates properly across year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482695#M135201</link>
      <description>&lt;P&gt;It is sorting correctly based upon the lexicographic ordering.&lt;/P&gt;

&lt;P&gt;If you want to sort by a section of the string, in this case the year, then you have a couple options:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Change the format of your field values so that the year is first. For example, 2019-06-16 will come before 2020-01-12. You can use something like &lt;CODE&gt;| eval Time=strftime(your_field,"%Y-%m-%d")&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Keep the current field format as-is, create a sorting field called something like dateSort which has the format in the previous item, sort by that, then remove the dateSort field.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 13 Jan 2020 19:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482695#M135201</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-01-13T19:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk not sorting Dates properly across year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482696#M135202</link>
      <description>&lt;P&gt;thanks .. how can I  create a sorting field called something like dateSort which has the format in the previous item, sort by that, then remove the dateSort field.?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 20:24:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482696#M135202</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2020-01-13T20:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk not sorting Dates properly across year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482697#M135203</link>
      <description>&lt;P&gt;Here is one way to do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval dateList="1/5/2020 1/12/2020 6/16/2019 6/23/2019 6/30/2019 7/7/2019"
| eval dateList=split(dateList," ") | mvexpand dateList | fields - _time
| eval dateSort=strftime(strptime(dateList,"%m/%d/%Y"),"%Y-%m-%d")
| sort + dateSort | fields - dateSort
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2020 20:32:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482697#M135203</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-01-13T20:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk not sorting Dates properly across year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482698#M135204</link>
      <description>&lt;P&gt;&lt;CODE&gt;... | eval datasort = strptime(your_field, "%m/%d/%Y")&lt;BR /&gt;
| sort datasort&lt;BR /&gt;
| fields - datasort&lt;BR /&gt;
| ...&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 20:33:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482698#M135204</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-01-13T20:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk not sorting Dates properly across year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482699#M135205</link>
      <description>&lt;P&gt;@richgalloway made a good point, my 4th line has an unnecessary strftime that was used for visualization purposes. You could easily just use this: &lt;CODE&gt;| eval dateSort=strptime(dateList,"%m/%d/%Y")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 20:43:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-not-sorting-Dates-properly-across-year/m-p/482699#M135205</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-01-13T20:43:18Z</dc:date>
    </item>
  </channel>
</rss>

