<?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 How to search based on the the time field from the event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-the-time-field-from-the-event/m-p/427656#M122437</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;I am having field called expirationdatetime in my event and its format is 2019-06-21T06:08:40.220082Z. My requirement is to get the count of users whose request going to expire in next 2 days.&lt;/P&gt;

&lt;P&gt;Built a search - &lt;CODE&gt;index="XXX" sourcetype="RRR" expirationdatetime=now+2d&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;When i hit the above expression, i didnt get any events.&lt;/P&gt;

&lt;P&gt;Help on this&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2019 06:42:54 GMT</pubDate>
    <dc:creator>bhuvanabala</dc:creator>
    <dc:date>2019-06-18T06:42:54Z</dc:date>
    <item>
      <title>How to search based on the the time field from the event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-the-time-field-from-the-event/m-p/427656#M122437</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;I am having field called expirationdatetime in my event and its format is 2019-06-21T06:08:40.220082Z. My requirement is to get the count of users whose request going to expire in next 2 days.&lt;/P&gt;

&lt;P&gt;Built a search - &lt;CODE&gt;index="XXX" sourcetype="RRR" expirationdatetime=now+2d&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;When i hit the above expression, i didnt get any events.&lt;/P&gt;

&lt;P&gt;Help on this&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 06:42:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-the-time-field-from-the-event/m-p/427656#M122437</guid>
      <dc:creator>bhuvanabala</dc:creator>
      <dc:date>2019-06-18T06:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the the time field from the event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-the-time-field-from-the-event/m-p/427657#M122438</link>
      <description>&lt;P&gt;@bhuvanabala,&lt;/P&gt;

&lt;P&gt;Does this help?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval time_given="2019-06-20T06:08:40.220082Z" 
| eval time_given_in_epoch_format=strptime(time_given,"%Y-%m-%dT%H:%M:%S.%Q") 
| eval time_2_days_from_now=relative_time(now(),"+2d") 
| eval time_2_days_from_now_human_readable=strftime(time_2_days_from_now,"%Y-%m-%d %H:%M:%S.%Q")
| eval breach=if(time_given_in_epoch_format&amp;gt;=time_2_days_from_now,1,0)
|table breach
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jun 2019 07:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-the-time-field-from-the-event/m-p/427657#M122438</guid>
      <dc:creator>pramit46</dc:creator>
      <dc:date>2019-06-18T07:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the the time field from the event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-the-time-field-from-the-event/m-p/427658#M122439</link>
      <description>&lt;P&gt;Hi @bhuvanabala,&lt;/P&gt;

&lt;P&gt;This should do the trick :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="XXX" sourcetype="RRR" 
|eval expirationdatetime=strptime(expirationdatetime,"%Y-%m-%dT%H:%M:%S.%Q") 
|where expirationdatetime &amp;lt; relative_time(now(), "-+2d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if it helps.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 19:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-the-time-field-from-the-event/m-p/427658#M122439</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-18T19:09:04Z</dc:date>
    </item>
  </channel>
</rss>

