<?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 calculated fields with strptime in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/calculated-fields-with-strptime/m-p/549157#M155789</link>
    <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;I have a _raw where I am extracting a timestamp. But this is in a bad format. So I wanted to have a "calculated field" (via the splunk interface option, not in the conf to which I dont have access). But while other calculated fields seem to work.&lt;BR /&gt;basically I have a field called "exTimeString". I want to create a calculated field exTimeStamp What I put into the eval field is:&lt;BR /&gt;strptime(exTimeString,"%Y-%m-%dT%H:%M:%S")&lt;/P&gt;&lt;P&gt;Unfortunately it doesn't work. Is it because of the strptime? Ormaybe the % characters cause issues here?&lt;/P&gt;</description>
    <pubDate>Fri, 23 Apr 2021 16:59:11 GMT</pubDate>
    <dc:creator>Bastelhoff</dc:creator>
    <dc:date>2021-04-23T16:59:11Z</dc:date>
    <item>
      <title>calculated fields with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculated-fields-with-strptime/m-p/549157#M155789</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;I have a _raw where I am extracting a timestamp. But this is in a bad format. So I wanted to have a "calculated field" (via the splunk interface option, not in the conf to which I dont have access). But while other calculated fields seem to work.&lt;BR /&gt;basically I have a field called "exTimeString". I want to create a calculated field exTimeStamp What I put into the eval field is:&lt;BR /&gt;strptime(exTimeString,"%Y-%m-%dT%H:%M:%S")&lt;/P&gt;&lt;P&gt;Unfortunately it doesn't work. Is it because of the strptime? Ormaybe the % characters cause issues here?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 16:59:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculated-fields-with-strptime/m-p/549157#M155789</guid>
      <dc:creator>Bastelhoff</dc:creator>
      <dc:date>2021-04-23T16:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: calculated fields with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculated-fields-with-strptime/m-p/549163#M155792</link>
      <description>&lt;P&gt;What is not working (because it looks like you have strptime correct)?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval exTimeStamp=strptime(exTimeString,"%Y-%m-%dT%H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;Can you share a sample event and how you have extracted exTimeString from it?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 17:26:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculated-fields-with-strptime/m-p/549163#M155792</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-23T17:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: calculated fields with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculated-fields-with-strptime/m-p/549169#M155794</link>
      <description>&lt;P&gt;Yeah, this eval works when I just convert the extracted field at runtime. But I'd like to have it calculated via "Calculated Fields" (as in Settings-&amp;gt;Fields-&amp;gt;Calculated Fields)&lt;/P&gt;&lt;P&gt;The original extraction is:&lt;BR /&gt;\"summary\"\:\"\{.*?\"timestamp\\\"\:\\\"(?&amp;lt;&lt;SPAN&gt;exTimeString&lt;/SPAN&gt;&amp;gt;.*?)\\\".*?\}&lt;/P&gt;&lt;P&gt;This then correctly generates a field&amp;nbsp;&lt;SPAN&gt;exTimeString with content like&amp;nbsp;&lt;BR /&gt;2021-04-23T17:27:21.000Z&lt;BR /&gt;&lt;BR /&gt;If I do a search with&lt;BR /&gt;index=myIndex&amp;nbsp;&lt;BR /&gt;|table&amp;nbsp;exTimeString&lt;BR /&gt;| eval exTimeStamp=strptime(exTimeString,"%Y-%m-%dT%H:%M:%S")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;that also works and returns a valid timstamp (which for example I could use as _time in timecharts)&lt;BR /&gt;&lt;BR /&gt;but if I put&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;strptime(exTimeString,"%Y-%m-%dT%H:%M:%S")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;into calculated fields instead, it does not work. The calculated field just doesnt show up.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 17:56:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculated-fields-with-strptime/m-p/549169#M155794</guid>
      <dc:creator>Bastelhoff</dc:creator>
      <dc:date>2021-04-23T17:56:04Z</dc:date>
    </item>
  </channel>
</rss>

