<?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 subtract 30 minutes from now() using eval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98563#M25371</link>
    <description>&lt;P&gt;It's actually very easy! You want:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval StartTimeInSecondsSince12AM = relative_time(now(),"-30m") | eval EndTimeInSecondsSince12AM = now()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;now()&lt;/CODE&gt; is the time that the search started, in Linux epoch time.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jul 2012 16:41:30 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-07-13T16:41:30Z</dc:date>
    <item>
      <title>How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98562#M25370</link>
      <description>&lt;P&gt;I would like to know how to subtract 30 minutes from the call to the now() function and set the value of a field called StartTime&lt;/P&gt;

&lt;P&gt;| eval StartTimeInSecondsSince12AM = SomeFunction(now() - 30) | eval EndTimeInSecondsSince12AM = SomeFunction(now())&lt;/P&gt;

&lt;P&gt;From there I want to  run a query like&lt;/P&gt;

&lt;P&gt;earliest = -30d latest = -1d | where SecondsSince12AM(_time) &amp;gt;= StarTimeInSecondsSince12AM AND SecondsSince12AM(_time) &amp;lt;= EndTimeInSecondsSince12AM&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:05:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98562#M25370</guid>
      <dc:creator>adoshi</dc:creator>
      <dc:date>2020-09-28T12:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98563#M25371</link>
      <description>&lt;P&gt;It's actually very easy! You want:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval StartTimeInSecondsSince12AM = relative_time(now(),"-30m") | eval EndTimeInSecondsSince12AM = now()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;now()&lt;/CODE&gt; is the time that the search started, in Linux epoch time.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2012 16:41:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98563#M25371</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-07-13T16:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98564#M25372</link>
      <description>&lt;P&gt;If I do that, I think it would have the data and time included in the value.  I just need the time part so that I can find the events that occurred in that time period for last 30 days.  So how do I just extract the time part is the question.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2012 17:08:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98564#M25372</guid>
      <dc:creator>adoshi</dc:creator>
      <dc:date>2012-07-13T17:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98565#M25373</link>
      <description>&lt;P&gt;So, you are looking for events that occurred at the same time of day, on different days? That's a different question...&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2012 18:15:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98565#M25373</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-07-13T18:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98566#M25374</link>
      <description>&lt;P&gt;If you are looking for events that occurred within a time of day, for a series of days, you will need a different approach.&lt;BR /&gt;
I will use this example: I want to know how many events occurred between 14:00 and 14:30 for each of the last 30 days.&lt;BR /&gt;
Here is how to do that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;searchcriteriahere earliest=-30d 
| eval eventHour=strftime(_time,"%H") | eval eventMin=strftime(_time,"%M")
| where eventHour=14 and eventMin&amp;lt;31
| bucket _time span=1d
| chart count by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And if the time needs to be based on "in the last 30 minutes" instead of a specific time:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;searchcriteriahere earliest=-30d 
| eval eventHour=strftime(_time,"%H") | eval eventMin=strftime(_time,"%M")
| eval curHour==strftime(now(),"%H") | eval curMin=strftime(now(),"%M")
| where (eventHour=curHour and eventMin &amp;gt; curMin - 30) or 
    (curMin &amp;lt; 30 and eventHour=curHour-1 and eventMin&amp;gt;curMin+30)
| bucket _time span=1d
| chart count by _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jul 2012 18:21:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98566#M25374</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-07-13T18:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98567#M25375</link>
      <description>&lt;P&gt;Thank you.  This is exactly what I need.  You are awesome.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2012 21:45:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98567#M25375</guid>
      <dc:creator>adoshi</dc:creator>
      <dc:date>2012-07-13T21:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98568#M25376</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;If not work, I can give a clue please &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=menu_ivr dnis=550621 | eval StartTime_7 = relative_time(now(),"-90000s@s") | eval EndTime_7 = relative_time(now(),"-86400s@s")| fields connectionID, _time, dnis, StartTime_7, EndTime_7 |eval StartTime_N=strftime(StartTime_7,"%Y-%m-%d %H:%M:%S") | eval EndTime_N=strftime(EndTime_7,"%Y-%m-%d %H:%M:%S") | eval time=strftime(_time,"%Y-%m-%d %H:%M:%S") | fields StartTime_N, connectionID, dnis, EndTime_N, time | where time &amp;gt; StartTime_N AND time &amp;gt; EndTime_N
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Sep 2016 18:27:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98568#M25376</guid>
      <dc:creator>vhsg</dc:creator>
      <dc:date>2016-09-23T18:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 30 minutes from now() using eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98569#M25377</link>
      <description>&lt;P&gt;hello, but this also gives negative minutes this correct?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 18:48:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-30-minutes-from-now-using-eval/m-p/98569#M25377</guid>
      <dc:creator>vhsg</dc:creator>
      <dc:date>2016-09-23T18:48:19Z</dc:date>
    </item>
  </channel>
</rss>

