<?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 compare data with last 7 days of data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364842#M107608</link>
    <description>&lt;P&gt;can you share sample output of below query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=* host="xxx" index="xxx" sourcetype="xxx" "Issue Type"="Bug" | streamstats dc(source) as distinct_source | head (distinct_source == 1) |table Created *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 12 Feb 2018 15:18:51 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2018-02-12T15:18:51Z</dc:date>
    <item>
      <title>How to compare data with last 7 days of data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364839#M107605</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've got a query that's failing at the "where" statement. I'm trying to show data in the last 7 days based on data i've imported. This is the query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=* host="xxx" index="xxx" sourcetype="xxx" "Issue Type"="Bug" | streamstats dc(source) as distinct_source | head (distinct_source == 1)  | eval NewTime=strptime(Created,"%d/%b/%y %H:%M %p") | eval _time=NewTime | eval epoch7days_ago=relative_time(now(), "-7d@d") | where _time&amp;gt;epoch7days_ago
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure why I'm getting no results at the where statement.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 11:55:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364839#M107605</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2018-02-12T11:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare data with last 7 days of data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364840#M107606</link>
      <description>&lt;P&gt;hey you can try something like this !&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=* host="xxx" index="xxx" sourcetype="xxx" "Issue Type"="Bug" 
| streamstats dc(source) as distinct_source 
| head (distinct_source == 1) 
| eval NewTime=strptime(Created,"%d/%b/%y %H:%M %p") 
| eval time=NewTime 
| eval epoch7days_ago=relative_time(now(), "-7d@d") 
| where time&amp;gt;epoch7days_ago
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you have assigned &lt;CODE&gt;Newtime&lt;/CODE&gt; to &lt;CODE&gt;_time&lt;/CODE&gt; it will automatically convert epoch time to readable time format and you can not compare readable time and epoch time.&lt;BR /&gt;
You can see that using below run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval NewTime=strptime(starthuman,"%A %b %d %H:%M:%S %y")  |table NewTime  |  eval _time=NewTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 12:12:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364840#M107606</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-02-12T12:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare data with last 7 days of data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364841#M107607</link>
      <description>&lt;P&gt;Hi @mayurr98, sorry, this didn't work. I didn't quite understand what you did here, unfortunately.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 15:03:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364841#M107607</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2018-02-12T15:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare data with last 7 days of data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364842#M107608</link>
      <description>&lt;P&gt;can you share sample output of below query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=* host="xxx" index="xxx" sourcetype="xxx" "Issue Type"="Bug" | streamstats dc(source) as distinct_source | head (distinct_source == 1) |table Created *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Feb 2018 15:18:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364842#M107608</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-12T15:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare data with last 7 days of data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364843#M107609</link>
      <description>&lt;P&gt;The date in the Created field has the format: 12/02/2018 10:30&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 15:48:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364843#M107609</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2018-02-12T15:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare data with last 7 days of data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364844#M107610</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=* host="xxx" index="xxx" sourcetype="xxx" "Issue Type"="Bug" 
 | streamstats dc(source) as distinct_source 
 | head (distinct_source == 1) 
 | eval NewTime=strptime(Created,"%d/%m/%Y %H:%M")
 | eval time=NewTime 
 | eval epoch7days_ago=relative_time(now(), "-7d@d") 
 | where time&amp;gt;epoch7days_ago
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Feb 2018 15:54:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364844#M107610</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-12T15:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare data with last 7 days of data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364845#M107611</link>
      <description>&lt;P&gt;Hey if you have the date in 12/02/2018 10:30 format then you should use &lt;CODE&gt;%d/%m/%Y %H:%M&lt;/CODE&gt;. Substitute this in the query provided by me.&lt;/P&gt;

&lt;P&gt;In my run anywhere example, I took the time converted in epoch and assigned to _time just to show that you can not assign epoch time to _time so in order to assign epoch time you should use other custom time field. So that is the reason I used &lt;CODE&gt;time&lt;/CODE&gt; instead of &lt;CODE&gt;_time&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;I hope you understand this.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:00:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-data-with-last-7-days-of-data/m-p/364845#M107611</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2020-09-29T18:00:06Z</dc:date>
    </item>
  </channel>
</rss>

