<?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: Can you help me with my query involving the eval command and strftime? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459853#M129755</link>
    <description>&lt;P&gt;hi @tb5821&lt;/P&gt;

&lt;P&gt;Did the answer below solve your problem? If so, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help ya. Thanks for posting!&lt;/P&gt;</description>
    <pubDate>Wed, 07 Nov 2018 21:53:46 GMT</pubDate>
    <dc:creator>mstjohn_splunk</dc:creator>
    <dc:date>2018-11-07T21:53:46Z</dc:date>
    <item>
      <title>Can you help me with my query involving the eval command and strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459849#M129751</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| eval lastChange=strftime(time_of_last_change,"%m-%d-%y %I:%M:%S %p") 
| eval timenow=now()
| eval last1hr=strftime(relative_time(now(), "-1h@s"), "%m-%d-%y %I:%M:%S %p")
| eval timenow=strftime(now(),"%m-%d-%y %I:%M:%S %p")
| eval actualchange= prev_count-count 
| where prev_count != count
| dedup namespace 
| table namespace actualchange prev_count count timenow lastChange last1hr diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;for some reason I can't seem to diff last1hr and lastChange! — what am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 02:21:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459849#M129751</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-11-07T02:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with my query involving the eval command and strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459850#M129752</link>
      <description>&lt;P&gt;even if I do  &lt;CODE&gt;| eval diff= last1hr-lastChange&lt;/CODE&gt; that diff field doesn't produce anything!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 02:31:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459850#M129752</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-11-07T02:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with my query involving the eval command and strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459851#M129753</link>
      <description>&lt;P&gt;tried &lt;CODE&gt;| eval diff = lastChange - last1hr | eval dur = tostring(diff, "duration")&lt;/CODE&gt; too&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 02:38:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459851#M129753</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-11-07T02:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with my query involving the eval command and strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459852#M129754</link>
      <description>&lt;P&gt;You are using &lt;CODE&gt;strftime&lt;/CODE&gt;, which is converting your times into text strings, which you can't do maths operations on.&lt;/P&gt;

&lt;P&gt;What format is &lt;CODE&gt;time_of_last_change&lt;/CODE&gt;? Is it a unix timestamp? If so, you can calculate the difference by doing &lt;CODE&gt;eval diff=relative_time(now(), "-1h@s") - time_of_last_change&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Otherwise, you most probably want to use the &lt;CODE&gt;strptime&lt;/CODE&gt; command, which converts times in text format into a unix timestamp, which is seconds. From there, you can calculate the time difference.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 03:05:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459852#M129754</guid>
      <dc:creator>sduff_splunk</dc:creator>
      <dc:date>2018-11-07T03:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with my query involving the eval command and strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459853#M129755</link>
      <description>&lt;P&gt;hi @tb5821&lt;/P&gt;

&lt;P&gt;Did the answer below solve your problem? If so, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help ya. Thanks for posting!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 21:53:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459853#M129755</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2018-11-07T21:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with my query involving the eval command and strftime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459854#M129756</link>
      <description>&lt;P&gt;Is &lt;CODE&gt;time_of_last_change&lt;/CODE&gt; in epoch? As sduff has indicated, you're trying to diff string/text values. Not going to work.&lt;/P&gt;

&lt;P&gt;Use &lt;CODE&gt;strptime&lt;/CODE&gt; to convert the string into an integer in epoch.&lt;/P&gt;

&lt;P&gt;You'll need to compare two different epoch values to make your &lt;CODE&gt;tostring(&amp;lt;val&amp;gt;, "duration")&lt;/CODE&gt; usable here.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval diff = tostring(relative_time(now(), "-1h") - time_of_last_change, "duration")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 01:28:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-my-query-involving-the-eval-command-and/m-p/459854#M129756</guid>
      <dc:creator>hcanivel_splunk</dc:creator>
      <dc:date>2018-11-09T01:28:56Z</dc:date>
    </item>
  </channel>
</rss>

