<?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 return a timestamp to an eval? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187819#M54134</link>
    <description>&lt;P&gt;Eval statements cannot contain subsearches.  Try this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=[redacted] sourcetype=[redacted] "[redacted]=[redacted]" | dedup "DATE" | sort +_time | head 1 | bucket _time span=1d | stats first(_time) as thedate | table thedate
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Aug 2015 14:46:58 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2015-08-27T14:46:58Z</dc:date>
    <item>
      <title>How to return a timestamp to an eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187817#M54132</link>
      <description>&lt;P&gt;I'm trying to search by a specific date, so I wanted to return the date to an eval, but when I run it, I get the message: &lt;CODE&gt;Error in 'eval' command: The expression is malformed. An unexpected character is reached at ')'.&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This is the search I'm running: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval thedate=[return index=[redacted] sourcetype=[redacted] "[redacted]=[redacted]" | dedup "DATE" | sort +_time | head 1 | bucket _time span=1d | stats first(_time) as _time] | table thedate
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;-------------------------------------- EDIT: 8/27/15 9:49am --------------------------------------&lt;BR /&gt;
So I realize now that I was using the return command incorrectly, here's what I'm getting now: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval thedate=[search index=[redacted] sourcetype=[redacted] "[redacted]=[redacted]" | dedup "DATE" | sort +_time | head 1 | bucket _time span=1d | return _time] | table thedate
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I'm still getting the error: &lt;CODE&gt;Error in 'eval' command: Fields cannot be assigned a boolean result. Instead, try if([bool expr], [expr], [expr])&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2015 14:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187817#M54132</guid>
      <dc:creator>sam_jacob</dc:creator>
      <dc:date>2015-08-27T14:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a timestamp to an eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187818#M54133</link>
      <description>&lt;P&gt;you can't perform an operation "as _time"&lt;/P&gt;

&lt;P&gt;you could do something like this:&lt;/P&gt;

&lt;P&gt;stats first(_time) as Time . . .&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2015 14:40:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187818#M54133</guid>
      <dc:creator>tskinnerivsec</dc:creator>
      <dc:date>2015-08-27T14:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a timestamp to an eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187819#M54134</link>
      <description>&lt;P&gt;Eval statements cannot contain subsearches.  Try this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=[redacted] sourcetype=[redacted] "[redacted]=[redacted]" | dedup "DATE" | sort +_time | head 1 | bucket _time span=1d | stats first(_time) as thedate | table thedate
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Aug 2015 14:46:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187819#M54134</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-08-27T14:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a timestamp to an eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187820#M54135</link>
      <description>&lt;P&gt;Ohh okay, I didn't know that. I think I need rethink this search query. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2015 14:53:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187820#M54135</guid>
      <dc:creator>sam_jacob</dc:creator>
      <dc:date>2015-08-27T14:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a timestamp to an eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187821#M54136</link>
      <description>&lt;P&gt;The eval does accept subsearches, but you need return the value instead of the field using return $fieldname. See this runanywhere sample&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval temp=[| gentimes start=-1 | eval endhuman="\"".endhuman."\""| return $endhuman]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your query would look like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval thedate=[search index=[redacted] sourcetype=[redacted] "[redacted]=[redacted]" | dedup "DATE" | sort +_time | head 1 | bucket _time span=1d | return $_time] | table thedate
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Aug 2015 16:49:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-a-timestamp-to-an-eval/m-p/187821#M54136</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-08-27T16:49:15Z</dc:date>
    </item>
  </channel>
</rss>

