<?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: convert timerange to epoch values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143067#M39730</link>
    <description>&lt;P&gt;It appears you also have to catch a value of "now" explicitly, i.e.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where mydate &amp;lt; case(isnum("$timepicker.latest$"), $timepicker.latest$, $timepicker.latest$="now", now(), 1=1, relative_time(now(), "$timepicker.latest$"))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Jul 2016 08:34:38 GMT</pubDate>
    <dc:creator>jeffland</dc:creator>
    <dc:date>2016-07-18T08:34:38Z</dc:date>
    <item>
      <title>convert timerange to epoch values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143061#M39724</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I want to use my timerange as a filter in a search on a dashboard, like this:&lt;BR /&gt;
    ..... | where mydate &amp;lt; $timepicker.latest$&lt;/P&gt;

&lt;P&gt;But i need to conver values like "@d" , "-1h" and so on to epoch. &lt;BR /&gt;
And the latest may be already in epoch format. Then I do not need to convert.&lt;BR /&gt;
How can I do this?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2014 15:17:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143061#M39724</guid>
      <dc:creator>0range</dc:creator>
      <dc:date>2014-07-15T15:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: convert timerange to epoch values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143062#M39725</link>
      <description>&lt;P&gt;For this notation you can use the &lt;CODE&gt;relative_time()&lt;/CODE&gt; function:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where mydate &amp;lt; relative_time(now(), "$timepicker.latest$")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, you first need to check whether it's a number or not and only apply this if it isn't:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where mydate &amp;lt; if(isnum("$timepicker.latest$"), $timepicker.latest$, relative_time(now(), "$timepicker.latest$"))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note, I'm not 100% certain if this catches every case imaginable or not - make sure you test everything your users will need later.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2014 15:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143062#M39725</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-07-15T15:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: convert timerange to epoch values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143063#M39726</link>
      <description>&lt;P&gt;If the same timepicker is used to define timerange for the search then, this should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search ..| where mydate &amp;lt; [|gentimes start=-1 | addinfo | eval search=info_max_time | table search]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The 'addinfo' command will create fields info_min_time (based on search's earliest time) and info_max_time (based on search's latest time) which are in epoch already.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:04:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143063#M39726</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T17:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: convert timerange to epoch values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143064#M39727</link>
      <description>&lt;P&gt;No, the timepicker is not the same&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2014 15:40:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143064#M39727</guid>
      <dc:creator>0range</dc:creator>
      <dc:date>2014-07-15T15:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: convert timerange to epoch values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143065#M39728</link>
      <description>&lt;P&gt;seems that @d is not compatible with relative_time function&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2014 15:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143065#M39728</guid>
      <dc:creator>0range</dc:creator>
      <dc:date>2014-07-15T15:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: convert timerange to epoch values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143066#M39729</link>
      <description>&lt;P&gt;It is. Run this dummy query to confirm:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as now | eval now = strftime(now(), "%+") | eval at_d = strftime(relative_time(now(), "@d"), "%+")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Jul 2014 15:47:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143066#M39729</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-07-15T15:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: convert timerange to epoch values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143067#M39730</link>
      <description>&lt;P&gt;It appears you also have to catch a value of "now" explicitly, i.e.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where mydate &amp;lt; case(isnum("$timepicker.latest$"), $timepicker.latest$, $timepicker.latest$="now", now(), 1=1, relative_time(now(), "$timepicker.latest$"))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 08:34:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-timerange-to-epoch-values/m-p/143067#M39730</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2016-07-18T08:34:38Z</dc:date>
    </item>
  </channel>
</rss>

