<?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 can i filter date? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371086#M6059</link>
    <description>&lt;P&gt;Is this "Report Month" text or Splunk _time? If it`s Splunk time you can use the time picker, you can also eval a new field based on _time with the epoch month and try to use a where month_epoch &amp;gt; epoch_base_month&lt;BR /&gt;
Another way can be eval a new field with year + month in number and filter like 1602 (for Feb 16), 1603 (for Mar 16), 1604 (for Apr 16)&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:23:03 GMT</pubDate>
    <dc:creator>gfreitas</dc:creator>
    <dc:date>2020-09-29T13:23:03Z</dc:date>
    <item>
      <title>How can i filter date?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371085#M6058</link>
      <description>&lt;P&gt;Hi all. I would like to ask on how can I filter a date with a format "Feb-16" "Month-Year" in search command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Report Month

May-15
Dec-15
Jan-16
Feb-16
Mar-16
Apr-16
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the result should be Feb-16 onward.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Report Month

Feb-16
Mar-16
Apr-16
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 07:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371085#M6058</guid>
      <dc:creator>mrccasi</dc:creator>
      <dc:date>2017-03-23T07:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can i filter date?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371086#M6059</link>
      <description>&lt;P&gt;Is this "Report Month" text or Splunk _time? If it`s Splunk time you can use the time picker, you can also eval a new field based on _time with the epoch month and try to use a where month_epoch &amp;gt; epoch_base_month&lt;BR /&gt;
Another way can be eval a new field with year + month in number and filter like 1602 (for Feb 16), 1603 (for Mar 16), 1604 (for Apr 16)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:23:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371086#M6059</guid>
      <dc:creator>gfreitas</dc:creator>
      <dc:date>2020-09-29T13:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can i filter date?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371087#M6060</link>
      <description>&lt;P&gt;take a look at this answer: &lt;A href="https://answers.splunk.com/answers/513047/search-two-fields-in-one-csv-lookup.html#comment-514036"&gt;https://answers.splunk.com/answers/513047/search-two-fields-in-one-csv-lookup.html#comment-514036&lt;/A&gt;&lt;BR /&gt;
you can use the same concept&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 12:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371087#M6060</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-03-23T12:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can i filter date?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371088#M6061</link>
      <description>&lt;P&gt;The &lt;CODE&gt;strptime&lt;/CODE&gt; function unfortunately does not include a default to the first day of the month when extracting &lt;CODE&gt;Mmm-yy&lt;/CODE&gt; or &lt;CODE&gt;YYYY-MM&lt;/CODE&gt; format dates.  Therefore, you have to concatenate a &lt;CODE&gt;01&lt;/CODE&gt; onto the end and tell splunk that the &lt;CODE&gt;01&lt;/CODE&gt; is the day.  &lt;/P&gt;

&lt;P&gt;This makes your test data... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval mydate="May-15 Dec-15 Jan-16 Feb-16 Mar-16 Apr-16" | makemv mydate | mvexpand mydate
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This converts it to epoch time and a display version of the epoch time...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval mydateEpoch=strptime(mydate."-01","%b-%y-%d")
| eval mydateDisplay=strftime(mydateEpoch,"%Y-%m-%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Either one of these filters for dates from Feb 2016 forward...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where mydateDisplay&amp;gt;="2016-02-01"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where mydateEpoch &amp;gt;= strptime("2016-02-01","%Y-%m-%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For efficiency reasons, you always want to filter out records as early as possible, before doing calculations, so this would be the proper order...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval mydate="May-15 Dec-15 Jan-16 Feb-16 Mar-16 Apr-16" | makemv mydate | mvexpand mydate

| eval mydateEpoch=strptime(mydate."-01","%b-%y-%d")
| where mydateEpoch &amp;gt;= strptime("2016-02-01","%Y-%m-%d")
| eval mydateDisplay=strftime(mydateEpoch,"%Y-%m-%d")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Mar 2017 14:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-i-filter-date/m-p/371088#M6061</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-23T14:17:27Z</dc:date>
    </item>
  </channel>
</rss>

