<?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: Filtering on multiple times in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-on-multiple-times/m-p/294459#M55943</link>
    <description>&lt;P&gt;can you filter on time like that in the where command?  If you can, very cool.  If not, you might want to use relative_time() instead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where LPR &amp;gt;= relative_time(now(),"-30d@d") AND LPR &amp;lt;= now() | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Mar 2018 22:47:35 GMT</pubDate>
    <dc:creator>maciep</dc:creator>
    <dc:date>2018-03-27T22:47:35Z</dc:date>
    <item>
      <title>Filtering on multiple times</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-on-multiple-times/m-p/294458#M55942</link>
      <description>&lt;P&gt;I have a search with two indexes. &lt;BR /&gt;
The first index needs to be run on all time, but I have a field within that index that I would like to filter on (it contains a date/time field as a string), I have another field within that index that I would also like to filter on (it also contains a date/time field as a string).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=BASE earliest=0
 | eval LPR = strptime(LastPolicyRequest, "%m/%d/%Y %I:%M:%S") 
 | where LPR &amp;gt;= "-30d@d" AND LPR &amp;lt;= "now"
| eval now_epoch = now() 
| eval valid_to_epoch = strptime(ValidTo, "%m/%d/%Y %I:%M:%S %p") 
| where valid_to_epoch &amp;lt; now_epoch
| table "WiFiMAC","LastPolicyRequest","ValidFrom","ValidTo" 
| rename WiFiMAC as hdr.macaddress 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4640i665DB052727F408D/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Today is 3/27/18, yet getting results for 2/24/18&lt;/P&gt;

&lt;P&gt;The query that I am joining needs to be set for 2 days&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=BASE earliest =-48h
    | eval indextime=strftime(_indextime,"%Y-%m-%d %H:%M:%S") 
    | eval Indextime =strptime(indextime,"%Y-%m-%d %H:%M:%S.%N") 
    | eval Time =strptime(_time,"%s") 
    | eval Minutes_Diff = round((Indextime - Time)/60,2) 
    | stats avg(Minutes_Diff) as Avg_Minutes_Diff stdev(Minutes_Diff) as StDev_Minutes_Diff min(Minutes_Diff) as Min_Minutes_Diff max(Minutes_Diff) as Max_Minutes_Diff count as count by hdr.macaddress hdr.locId hdr.deviceModel hdr.firmwareVersion 
    | eval Avg_Minutes_Diff = round(Avg_Minutes_Diff,2) 
    | rename count as "Sample Size" 
    | table "hdr.macaddress", "Avg_Minutes_Diff", "StDev_Minutes_Diff", "Min_Minutes_Diff", "Max_Minutes_Diff", "Sample Size"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4641i2E3F1BD436FC40EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Here is the joined search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=BASE earliest=0
 | eval LPR = strptime(LastPolicyRequest, "%m/%d/%Y %I:%M:%S %p") 
 | where LPR &amp;gt;= "-30d@d" AND LPR &amp;lt;= "now"
| eval now_epoch = now() 
| eval valid_to_epoch = strptime(ValidTo, "%m/%d/%Y %I:%M:%S %p") 
| eval twenty_days_epoch=relative_time(now(), "-20d@d") 
| where valid_to_epoch &amp;lt; now_epoch
| table "WiFiMAC","LastPolicyRequest","ValidFrom","ValidTo" 
| rename WiFiMAC as hdr.macaddress 
| join type=left hdr.macaddress 
    [ search index=BASE earliest =-48h
    | eval indextime=strftime(_indextime,"%Y-%m-%d %H:%M:%S") 
    | eval Indextime =strptime(indextime,"%Y-%m-%d %H:%M:%S.%N") 
    | eval Time =strptime(_time,"%s") 
    | eval Minutes_Diff = round((Indextime - Time)/60,2) 
    | stats avg(Minutes_Diff) as Avg_Minutes_Diff stdev(Minutes_Diff) as StDev_Minutes_Diff min(Minutes_Diff) as Min_Minutes_Diff max(Minutes_Diff) as Max_Minutes_Diff count as count by hdr.macaddress hdr.locId hdr.deviceModel hdr.firmwareVersion 
    | eval Avg_Minutes_Diff = round(Avg_Minutes_Diff,2) 
    | rename count as "Sample Size" 
    | table "hdr.macaddress", "Avg_Minutes_Diff", "StDev_Minutes_Diff", "Min_Minutes_Diff", "Max_Minutes_Diff", "Sample Size" ] 
| table "hdr.macaddress","Avg_Minutes_Diff", "StDev_Minutes_Diff", "Min_Minutes_Diff", "Max_Minutes_Diff","ValidFrom","ValidTo","LastPolicyRequest", "Sample Size"
| dedup hdr.macaddress
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4642i60D69C21CEA61B23/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Any Ideas as to what I am doing wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 18:57:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-on-multiple-times/m-p/294458#M55942</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2018-03-27T18:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering on multiple times</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-on-multiple-times/m-p/294459#M55943</link>
      <description>&lt;P&gt;can you filter on time like that in the where command?  If you can, very cool.  If not, you might want to use relative_time() instead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where LPR &amp;gt;= relative_time(now(),"-30d@d") AND LPR &amp;lt;= now() | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Mar 2018 22:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-on-multiple-times/m-p/294459#M55943</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2018-03-27T22:47:35Z</dc:date>
    </item>
  </channel>
</rss>

