<?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: Check if first occurrence of event is today in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Check-if-first-occurrence-of-event-is-today/m-p/497657#M194820</link>
    <description>&lt;P&gt;Use eval instead of fieldformat. &lt;/P&gt;

&lt;P&gt;That fieldformat command changes the appearance of the results without changing the underlying value of the field. Refer to &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Fieldformat"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Fieldformat&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Dec 2019 04:30:36 GMT</pubDate>
    <dc:creator>shandr</dc:creator>
    <dc:date>2019-12-06T04:30:36Z</dc:date>
    <item>
      <title>Check if first occurrence of event is today</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Check-if-first-occurrence-of-event-is-today/m-p/497656#M194819</link>
      <description>&lt;P&gt;I'm trying to check if the first occurrence of an event is today using the query below. However, I keep getting &lt;CODE&gt;result&lt;/CODE&gt; as "0", indicating that there was no match, even though some of the dates are the same.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;mysearch | stats earliest(_time) as firstSeen by item | fieldformat firstSeen=strftime(firstSeen, "%d-%m-%Y") | eval today_date=strftime(now(), "%d-%m-%Y") | eval result=if(firstSeen=today_date, "1", "0")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;All of my results are "0", even for entries like the one below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;item     firstSeen     today_date    result
ABC      06-12-2019    06-12-2019    0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I even tried to change the if-condition to &lt;CODE&gt;firstSeen!=today_date&lt;/CODE&gt; just to see what happens, and my &lt;CODE&gt;result&lt;/CODE&gt; is still all '0', even for those where the dates don't match. It doesn't seem like the if-condition is being evaluated.&lt;/P&gt;

&lt;P&gt;What should I do?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 03:02:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Check-if-first-occurrence-of-event-is-today/m-p/497656#M194819</guid>
      <dc:creator>wu_weidong</dc:creator>
      <dc:date>2019-12-06T03:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Check if first occurrence of event is today</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Check-if-first-occurrence-of-event-is-today/m-p/497657#M194820</link>
      <description>&lt;P&gt;Use eval instead of fieldformat. &lt;/P&gt;

&lt;P&gt;That fieldformat command changes the appearance of the results without changing the underlying value of the field. Refer to &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Fieldformat"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Fieldformat&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 04:30:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Check-if-first-occurrence-of-event-is-today/m-p/497657#M194820</guid>
      <dc:creator>shandr</dc:creator>
      <dc:date>2019-12-06T04:30:36Z</dc:date>
    </item>
  </channel>
</rss>

