<?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 use the time input field to calculate time as seconds? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349892#M103572</link>
    <description>&lt;P&gt;I am not sure of the purpose of this calculation, however, Earliest and Latest Time selected in a Search through Input Control are available as &lt;CODE&gt;$job.searchLatestTime$&lt;/CODE&gt; and &lt;CODE&gt;$job.searchEarliestTime$&lt;/CODE&gt; in &lt;CODE&gt;preview&lt;/CODE&gt; and &lt;CODE&gt;finalized&lt;/CODE&gt; search event handler. You can use &lt;CODE&gt;eval&lt;/CODE&gt; attribute to calculate time span in seconds applied to search via time input.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;|makeresults &amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$field3.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$field3.latest$&amp;lt;/latest&amp;gt;
      &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
      &amp;lt;preview&amp;gt;
        &amp;lt;eval token="SearchSpan"&amp;gt;$job.searchLatestTime$-$job.searchEarliestTime$&amp;lt;/eval&amp;gt;  
      &amp;lt;/preview&amp;gt;
    &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can then use the token in your form like in the following HTML panel&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;html&amp;gt;
    Selected Time Span=$SearchSpan$
  &amp;lt;/html&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Mar 2017 20:29:27 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-03-09T20:29:27Z</dc:date>
    <item>
      <title>How to use the time input field to calculate time as seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349887#M103567</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;In my form, I have labeled my time input as field3 such as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     input type="time" token="field3" searchWhenChanged="true"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the search below it, I want to calculate the time as seconds, using &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval time_s=$field3.latest$ - $field3.earliest$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I got error.&lt;/P&gt;

&lt;P&gt;Any idea how to use the Time Input field to calculate the time in seconds?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 18:56:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349887#M103567</guid>
      <dc:creator>abzmhzsplunk</dc:creator>
      <dc:date>2017-03-09T18:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the time input field to calculate time as seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349888#M103568</link>
      <description>&lt;P&gt;Whenever you get an error, you should report the error text, too.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349888#M103568</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-09T19:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the time input field to calculate time as seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349889#M103569</link>
      <description>&lt;P&gt;As an alternative, you can do this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | addinfo | eval time_s = info_max_time - info_min_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:38:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349889#M103569</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-09T19:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the time input field to calculate time as seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349890#M103570</link>
      <description>&lt;P&gt;That should definitely work.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:39:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349890#M103570</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-09T19:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the time input field to calculate time as seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349891#M103571</link>
      <description>&lt;P&gt;Upvote because for this usage, there's no reason to futz with anything else.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349891#M103571</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-09T19:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the time input field to calculate time as seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349892#M103572</link>
      <description>&lt;P&gt;I am not sure of the purpose of this calculation, however, Earliest and Latest Time selected in a Search through Input Control are available as &lt;CODE&gt;$job.searchLatestTime$&lt;/CODE&gt; and &lt;CODE&gt;$job.searchEarliestTime$&lt;/CODE&gt; in &lt;CODE&gt;preview&lt;/CODE&gt; and &lt;CODE&gt;finalized&lt;/CODE&gt; search event handler. You can use &lt;CODE&gt;eval&lt;/CODE&gt; attribute to calculate time span in seconds applied to search via time input.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;|makeresults &amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$field3.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$field3.latest$&amp;lt;/latest&amp;gt;
      &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
      &amp;lt;preview&amp;gt;
        &amp;lt;eval token="SearchSpan"&amp;gt;$job.searchLatestTime$-$job.searchEarliestTime$&amp;lt;/eval&amp;gt;  
      &amp;lt;/preview&amp;gt;
    &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can then use the token in your form like in the following HTML panel&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;html&amp;gt;
    Selected Time Span=$SearchSpan$
  &amp;lt;/html&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 20:29:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349892#M103572</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-09T20:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the time input field to calculate time as seconds?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349893#M103573</link>
      <description>&lt;P&gt;The &lt;EM&gt;really&lt;/EM&gt; nice thing about this option is that you might have multiple timepickers and even then, you might override all of them with &lt;CODE&gt;earliest=&lt;/CODE&gt;; this should handle every case with no thinking/planning/upkeep.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 20:54:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-time-input-field-to-calculate-time-as-seconds/m-p/349893#M103573</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-09T20:54:33Z</dc:date>
    </item>
  </channel>
</rss>

