<?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: Strptime bug with fields with spaces or periods in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489883#M136828</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval field_sample=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval field.sample=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval "field sample"=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval result1=strptime(field_sample, "%b %e, %Y %H:%M:%S %Z")
| eval result2=strptime(field.sample, "%b %e, %Y %H:%M:%S %Z")
| eval result3=strptime("field sample", "%b %e, %Y %H:%M:%S %Z")
| eval result2_dash=strptime('field.sample', "%b %e, %Y %H:%M:%S %Z")
| eval result3_dash=strptime('field sample', "%b %e, %Y %H:%M:%S %Z")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Interestingly, the field in the case of function arguments needs to be enclosed in single quotes.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Nov 2019 14:15:18 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2019-11-25T14:15:18Z</dc:date>
    <item>
      <title>Strptime bug with fields with spaces or periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489882#M136827</link>
      <description>&lt;P&gt;I came across this bug today when using strptime. Strptime does not work on field names that have spaces or periods. &lt;BR /&gt;
For example,&lt;BR /&gt;
epochtime=strptime(first_discovered, "%b %e, %Y %H:%M:%S %Z") works&lt;/P&gt;

&lt;P&gt;but &lt;/P&gt;

&lt;P&gt;epochtime=strptime(first.discovered, "%b %e, %Y %H:%M:%S %Z") &lt;BR /&gt;
and&lt;BR /&gt;
epochtime=strptime("first discovered", "%b %e, %Y %H:%M:%S %Z") &lt;/P&gt;

&lt;P&gt;do not work.&lt;BR /&gt;
Is there a place to fill out a bug report?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:06:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489882#M136827</guid>
      <dc:creator>jlucas4</dc:creator>
      <dc:date>2019-11-25T14:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Strptime bug with fields with spaces or periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489883#M136828</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval field_sample=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval field.sample=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval "field sample"=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval result1=strptime(field_sample, "%b %e, %Y %H:%M:%S %Z")
| eval result2=strptime(field.sample, "%b %e, %Y %H:%M:%S %Z")
| eval result3=strptime("field sample", "%b %e, %Y %H:%M:%S %Z")
| eval result2_dash=strptime('field.sample', "%b %e, %Y %H:%M:%S %Z")
| eval result3_dash=strptime('field sample', "%b %e, %Y %H:%M:%S %Z")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Interestingly, the field in the case of function arguments needs to be enclosed in single quotes.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:15:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489883#M136828</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-25T14:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Strptime bug with fields with spaces or periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489884#M136829</link>
      <description>&lt;P&gt;It is not a bug; use &lt;CODE&gt;single-quotes&lt;/CODE&gt;, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;epochtime=strptime('first discovered', "%b %e, %Y %H:%M:%S %Z")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is for field names in other places, too.  Sometimes you need &lt;CODE&gt;double-quotes&lt;/CODE&gt;, other times &lt;CODE&gt;single-quotes&lt;/CODE&gt;, depending on where/how the field name is used.  Whitespace in field names is &lt;EM&gt;EVIL&lt;/EM&gt;.  ONLY do so on the VERY last line of your SPL with &lt;CODE&gt;| rename benevolentFieldName AS "Evil FIeld Name"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:17:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489884#M136829</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-25T15:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Strptime bug with fields with spaces or periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489885#M136830</link>
      <description>&lt;P&gt;I completely agree, spaces are evil. Unfortunately, we were monitoring a csv with whitespaces in the field names. Now, we are going to use SEDCMD-replacespace in props.conf so we don't run into that issue anymore.&lt;/P&gt;

&lt;P&gt;Do you know what is the reasoning behind not allowing double-quotes in this instance?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:35:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489885#M136830</guid>
      <dc:creator>jlucas4</dc:creator>
      <dc:date>2019-11-25T15:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Strptime bug with fields with spaces or periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489886#M136831</link>
      <description>&lt;P&gt;Hi @jlucas4 ,&lt;/P&gt;

&lt;P&gt;If you see the splunk documentation for eval command , that would probably answer your question. I am pasting those line below,&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;If the expression references a field name that contains non-alphanumeric characters, other than the underscore ( _ ) character, the field name needs to be surrounded by single quotation marks. For example, if the field name is server-1 you specify the field name like this new=count+'server-1'.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;If the expression references a literal string, that string needs to be surrounded by double quotation marks. For example, if the string you want to use is server- you specify the string like this new="server-".host.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Eval"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;

&lt;P&gt;Sid&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:55:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489886#M136831</guid>
      <dc:creator>techiesid</dc:creator>
      <dc:date>2019-11-25T15:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Strptime bug with fields with spaces or periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489887#M136832</link>
      <description>&lt;P&gt;The use of &lt;CODE&gt;double-quotes&lt;/CODE&gt; both in Splunk and most other languages is generally an indication of a &lt;CODE&gt;object type&lt;/CODE&gt; of &lt;CODE&gt;string literal&lt;/CODE&gt;.  The fact that sometimes it is used otherwise is unfortunate.  In splunk, you can always use &lt;CODE&gt;$&lt;/CODE&gt; to indicate &lt;CODE&gt;this is a field name&lt;/CODE&gt; but I generally do not propose this because eventually most searches end up inside of dashboards/macro/foreach/map and then those searches break.  So the general approach should be:&lt;BR /&gt;
0: DO NOT use spaces in field names but, if you absolutely must:&lt;BR /&gt;
1: Make sure it works in SPL with &lt;CODE&gt;$fiend name$&lt;/CODE&gt;.&lt;BR /&gt;
2: Try &lt;CODE&gt;'fiend name'&lt;/CODE&gt; and if that works, done; otherwise&lt;BR /&gt;
3: Try &lt;CODE&gt;"fiend name"&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 16:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489887#M136832</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-25T16:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Strptime bug with fields with spaces or periods</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489888#M136833</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval field_sample=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval field.sample=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval "field sample"=strftime(_time,"%b %e, %Y %H:%M:%S %Z")
| eval result1=strptime(field_sample, "%b %e, %Y %H:%M:%S %Z")
| eval result2=strptime(field.sample, "%b %e, %Y %H:%M:%S %Z")
| eval result3=strptime("field sample", "%b %e, %Y %H:%M:%S %Z")
| eval result2_dash=strptime('field.sample', "%b %e, %Y %H:%M:%S %Z")
| eval result3_dash=strptime('field sample', "%b %e, %Y %H:%M:%S %Z")
| eval result2_dash_dash=strptime($field.sample$, "%b %e, %Y %H:%M:%S %Z")
| eval result3_dash_dash=strptime($field sample$, "%b %e, %Y %H:%M:%S %Z")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works, awesome&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 18:06:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strptime-bug-with-fields-with-spaces-or-periods/m-p/489888#M136833</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-25T18:06:05Z</dc:date>
    </item>
  </channel>
</rss>

