<?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 Extract data for last 3 months in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-for-last-3-months/m-p/309999#M93012</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am searching from a csv lookup.&lt;BR /&gt;
The CSV contains fields --&amp;gt; &lt;BR /&gt;
1. Reporting Month &amp;amp; Year --&amp;gt;17-Jan, 17-Feb, so on...&lt;BR /&gt;
2. Account name --&amp;gt; these accounts have had transactions in the months reported in the CSV&lt;/P&gt;

&lt;P&gt;My requirement is to extract the accounts, that have been active in the last 3 months on the basis of Reporting month &amp;amp; year.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2017 22:19:15 GMT</pubDate>
    <dc:creator>aartivig289</dc:creator>
    <dc:date>2017-07-11T22:19:15Z</dc:date>
    <item>
      <title>Extract data for last 3 months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-for-last-3-months/m-p/309999#M93012</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am searching from a csv lookup.&lt;BR /&gt;
The CSV contains fields --&amp;gt; &lt;BR /&gt;
1. Reporting Month &amp;amp; Year --&amp;gt;17-Jan, 17-Feb, so on...&lt;BR /&gt;
2. Account name --&amp;gt; these accounts have had transactions in the months reported in the CSV&lt;/P&gt;

&lt;P&gt;My requirement is to extract the accounts, that have been active in the last 3 months on the basis of Reporting month &amp;amp; year.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 22:19:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-for-last-3-months/m-p/309999#M93012</guid>
      <dc:creator>aartivig289</dc:creator>
      <dc:date>2017-07-11T22:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data for last 3 months</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-data-for-last-3-months/m-p/310000#M93013</link>
      <description>&lt;P&gt;Assuming that the field for the reporting month and year is named "datetime", try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup your.csv
| eval current_year = strftime(now(),"%Y")
| eval epoch_time = strptime(datetime . "-" .  current_year,"%d-%m-%Y")
| eval epoch_time = if(epoch_time&amp;lt;=now(),epoch_time,relative_time(epoch_time,"-1year")
| where epoch_time &amp;gt; relative_time(now(),"-3mon@mon")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This was a little tricky because of the lack of a year in the timestamp. The second line of the search picks up the current year (when the search is running) - right now that would be 2017. The third line appends this to the datetime from the csv.&lt;BR /&gt;
But what if the datetime from the csv is 29-Dec? Then the resulting epoch_time would be December 29, 2017 - clearly wrong!&lt;BR /&gt;
So the 4th line tests: if the epoch_time is AFTER now, then subtract a year from it.&lt;BR /&gt;
After all of that, filter the events, keeping only those with a datetime in the last 3 months.&lt;/P&gt;

&lt;P&gt;If needed, you could summarize at the end by adding something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count by Account
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:50:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-data-for-last-3-months/m-p/310000#M93013</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2020-09-29T14:50:34Z</dc:date>
    </item>
  </channel>
</rss>

