<?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: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137348#M37631</link>
    <description>&lt;P&gt;To compare two fields, you must use &lt;CODE&gt;where&lt;/CODE&gt;, not &lt;CODE&gt;search&lt;/CODE&gt;, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... |  where date_mday=today_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The reason is that the RHV for &lt;CODE&gt;search&lt;/CODE&gt; is always a string-literal.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jun 2015 16:23:49 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-06-05T16:23:49Z</dc:date>
    <item>
      <title>Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137346#M37629</link>
      <description>&lt;P&gt;So, I need to compare counts over multiple days, but I also need to filter the results to only show the count difference for the current day (compared to yesterday). For some reason, I can't get Splunk to understand that "5 = 5" (today's date) so it won't filter the results. Here's a simplified version of the query that you can test:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-72h latest=now index=_internal log_level=ERROR 
| stats count as ErrorCount by date_mday sourcetype 
| sort sourcetype 
| streamstats current=f last(ErrorCount) as LastErrorCount by sourcetype 
| eval ErrorCountDiff=ErrorCount-LastErrorCount
| eval today_mday=strftime(now(), "%e")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I want is only the rows where date_mday is equal to today_mday. However, if I add:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search date_mday=today_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It returns zero results. As does:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where date_mday=today_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And if I do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | search date_mday!=today_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;it returns ALL results (instead of just excluding today) (same result for where), so for some reason Splunk can't evaluate that both numbers are equal. &lt;/P&gt;

&lt;P&gt;I have tried converting both fields "tostring", and both fields "tonumber", and then applying the "date_mday=today_mday" filter, but it still returns zero results.&lt;/P&gt;

&lt;P&gt;Does anyone have an idea on how I can make Splunk understand that "5 = 5"? (today's date)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:08:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137346#M37629</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2020-09-28T20:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137347#M37630</link>
      <description>&lt;P&gt;Just a side note, I realize I could limit the time range more and do a fillnull on ErrorCountDiff, but this is a simplified version of the search I'm doing, which does require multiple days of counts.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 16:08:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137347#M37630</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-06-05T16:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137348#M37631</link>
      <description>&lt;P&gt;To compare two fields, you must use &lt;CODE&gt;where&lt;/CODE&gt;, not &lt;CODE&gt;search&lt;/CODE&gt;, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... |  where date_mday=today_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The reason is that the RHV for &lt;CODE&gt;search&lt;/CODE&gt; is always a string-literal.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 16:23:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137348#M37631</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-05T16:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137349#M37632</link>
      <description>&lt;P&gt;This also returns zero results.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 16:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137349#M37632</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-06-05T16:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137350#M37633</link>
      <description>&lt;P&gt;Then it is because the field &lt;CODE&gt;date_mday&lt;/CODE&gt; never has the same value as the field &lt;CODE&gt;today_mday&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 16:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137350#M37633</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-05T16:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137351#M37634</link>
      <description>&lt;P&gt;I'm guessing you didn't run my test query, because it's pretty obvious that it does.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 16:53:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137351#M37634</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-06-05T16:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137352#M37635</link>
      <description>&lt;P&gt;The problem is that &lt;CODE&gt;today_mday&lt;/CODE&gt; is a string with a leading space; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-72h latest=now index=_internal log_level=ERROR 
| stats count as ErrorCount by date_mday sourcetype 
| sort sourcetype 
| streamstats current=f last(ErrorCount) as LastErrorCount by sourcetype 
| eval ErrorCountDiff=ErrorCount-LastErrorCount
| eval today_mday=tonumber(strftime(now(), "%e")) | where today_mday=date_mday
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jun 2015 17:20:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137352#M37635</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-05T17:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137353#M37636</link>
      <description>&lt;P&gt;This also returns 0 results&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 17:28:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137353#M37636</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-06-05T17:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137354#M37637</link>
      <description>&lt;P&gt;I don't think there is a leading space (I know the docs say there is, but maybe it's because we are still in the single digit days of the month), because even if I do...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-72h latest=now index=_internal log_level=ERROR 
 | stats count as ErrorCount by date_mday sourcetype 
 | sort sourcetype 
 | streamstats current=f last(ErrorCount) as LastErrorCount by sourcetype 
 | eval ErrorCountDiff=ErrorCount-LastErrorCount
 | eval today_mday=strftime(now(), "%e")
 | replace " " with "" in today_mday
 | eval today_mday=tonumber(today_mday)
 | where today_mday=date_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I still get 0 results. This is starting to look like a bug.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 17:30:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137354#M37637</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-06-05T17:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137355#M37638</link>
      <description>&lt;P&gt;Yes, I am struggling to get Splunk to interpret &lt;CODE&gt;today_mday&lt;/CODE&gt; as a number/int but I am definitely correct in the "leading space" theory as you can see by this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-72h latest=now index=_internal log_level=ERROR 
| stats count as ErrorCount by date_mday sourcetype 
| sort sourcetype 
| streamstats current=f last(ErrorCount) as LastErrorCount by sourcetype 
| eval ErrorCountDiff=ErrorCount-LastErrorCount
| eval today_mday=strftime(now(), "%e") | eval combined="&amp;lt;" . date_mday . ":" . today_mday . "&amp;gt;" | stats count by date_mday,today_mday,combined
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jun 2015 17:39:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137355#M37638</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-05T17:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137356#M37639</link>
      <description>&lt;P&gt;So, I finally got it. Splunk must have some kind of unchangeable format for the "date_mday" field, because no matter what I did, I couldn't make it match my today_mdate even though it had the same field value.  &lt;/P&gt;

&lt;P&gt;I ended up creating my own date_mday field using _time with strftime, AND using an eval, THEN it finally worked. I still think this is a bug, because it shouldn't be this hard to tell Splunk that I need results where 5=5.&lt;/P&gt;

&lt;P&gt;Anyway, here's the query I built if anyone ever needs to do something similar:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-72h latest=now index=_internal log_level=ERROR 
 | eval new_date_mday=strftime(_time, "%e")
 | stats count as ErrorCount by new_date_mday sourcetype 
 | eval today_mday=strftime(now(), "%e")
 | sort sourcetype 
 | streamstats current=f last(ErrorCount) as LastErrorCount by sourcetype 
 | eval ErrorCountDiff=ErrorCount-LastErrorCount
 | eval IsToday=if(like(new_date_mday, today_mday), "Yes", "No")
 | where IsToday="Yes"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:08:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137356#M37639</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2020-09-28T20:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137357#M37640</link>
      <description>&lt;P&gt;I opened a bug case 244781:&lt;BR /&gt;
&lt;A href="https://splunkcommunities.force.com/customers/5003300000nfPDb"&gt;https://splunkcommunities.force.com/customers/5003300000nfPDb&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 18:15:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137357#M37640</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-05T18:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137358#M37641</link>
      <description>&lt;P&gt;Here is a very interesting thing I noticed today: If a value has been created as a number, it will show right-justified in the column, but if it has been created as a string, it will show left-justified. HOW COOL IS THAT!!! I wonder how long that has been in Splunk and if it is actually documented anywhere?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/241582/how-can-i-tell-a-field-values-type-number-or-strin.html"&gt;http://answers.splunk.com/answers/241582/how-can-i-tell-a-field-values-type-number-or-strin.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2015 17:19:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137358#M37641</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-08T17:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't Splunk believe that date_mday = today_mday? (5 is equal to 5, right?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137359#M37642</link>
      <description>&lt;P&gt;Splunk has acknowledged that &lt;CODE&gt;tonumber&lt;/CODE&gt; should ignore bounding whitespace and bugifix SPL-102836 is being targeted for the 6.2.5 maintenance release which should be available Sept/Oct 2015.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2015 20:41:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-Splunk-believe-that-date-mday-today-mday-5-is-equal/m-p/137359#M37642</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-10T20:41:47Z</dc:date>
    </item>
  </channel>
</rss>

