<?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 converting to an epoch date format using strptime in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255660#M189486</link>
    <description>&lt;P&gt;I’m trying to extract the date and time from the Winevent log when an unexpected shutdown has occurred(EventCode=6008)&lt;BR /&gt;
The message in the event is below:&lt;BR /&gt;
The previous system shutdown at 7:53:08 AM on 3/2/2016 was unexpected. &lt;/P&gt;

&lt;P&gt;I created two extracted fields to capture the shutdown date and time respectively: shutdown date(3/2/2016) and shutdown time(7:53:08). The code below joins the two fields together and inputs them into the strptime function.&lt;BR /&gt;
This function however doesn’t return a value. However, if I  pass a hardcoded value to strptime(“3/2/2016 7:53:08 AM”) it returns an epoch value. Can someone help? thanks.&lt;/P&gt;

&lt;P&gt;index=wineventlog EventCode=6008&lt;BR /&gt;
| Eval combo = shutdown_date + “ “ +   shutdown_time | eval otime = strptime(combo, “%m%d%Y%I:M:%S %p”)&lt;BR /&gt;
Table otime&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 09:09:10 GMT</pubDate>
    <dc:creator>pc1234</dc:creator>
    <dc:date>2020-09-29T09:09:10Z</dc:date>
    <item>
      <title>converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255660#M189486</link>
      <description>&lt;P&gt;I’m trying to extract the date and time from the Winevent log when an unexpected shutdown has occurred(EventCode=6008)&lt;BR /&gt;
The message in the event is below:&lt;BR /&gt;
The previous system shutdown at 7:53:08 AM on 3/2/2016 was unexpected. &lt;/P&gt;

&lt;P&gt;I created two extracted fields to capture the shutdown date and time respectively: shutdown date(3/2/2016) and shutdown time(7:53:08). The code below joins the two fields together and inputs them into the strptime function.&lt;BR /&gt;
This function however doesn’t return a value. However, if I  pass a hardcoded value to strptime(“3/2/2016 7:53:08 AM”) it returns an epoch value. Can someone help? thanks.&lt;/P&gt;

&lt;P&gt;index=wineventlog EventCode=6008&lt;BR /&gt;
| Eval combo = shutdown_date + “ “ +   shutdown_time | eval otime = strptime(combo, “%m%d%Y%I:M:%S %p”)&lt;BR /&gt;
Table otime&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255660#M189486</guid>
      <dc:creator>pc1234</dc:creator>
      <dc:date>2020-09-29T09:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255661#M189487</link>
      <description>&lt;P&gt;Mind the capitalization and the spaces here ....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... base_search ... | eval combo = shutdown_date + " " + shutdown_time | eval otime = strptime(combo, "%m/%d/%Y %I:%M:%S %p") | table otime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should do it. Maybe try a &lt;CODE&gt;table combo&lt;/CODE&gt; to see what the field &lt;CODE&gt;combo&lt;/CODE&gt; actually contains.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 15:09:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255661#M189487</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2016-03-21T15:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255662#M189488</link>
      <description>&lt;P&gt;Based on what you said, I tried the following -&lt;BR /&gt;
| eval timestamp=strptime("3/2/2016 7:53:08 AM", "%m%d%Y%I:M:%S %p") and nothing comes back.&lt;/P&gt;

&lt;P&gt;"3/2/2016 7:53:08 AM" doesn't seem to match the "%m%d%Y%I:M:%S %p" part.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 15:33:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255662#M189488</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2016-03-21T15:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255663#M189489</link>
      <description>&lt;P&gt;You're combining the fields by adding a space in between but your time format in strptime command doesn't include space. Add a space after %Y, and it should work fine.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 15:33:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255663#M189489</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-21T15:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255664#M189490</link>
      <description>&lt;P&gt;Right - | eval timestamp=strptime("3/2/2016 7:53:08 AM", "%m/%d/%Y %I:%M:%S %p") works.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 15:50:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255664#M189490</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2016-03-21T15:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255665#M189491</link>
      <description>&lt;P&gt;I added a space after %Y and still do not get results(with a table otime statement. ). With a table otime combo statement  the combo displays correctly "3/2/2016 7:53:08 AM" but no values are displayed for otime.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 17:39:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255665#M189491</guid>
      <dc:creator>pc1234</dc:creator>
      <dc:date>2016-03-21T17:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255666#M189492</link>
      <description>&lt;P&gt;First, there seems to be a typo in the time format for strftime, instead of &lt;CODE&gt;%M&lt;/CODE&gt;, its just &lt;CODE&gt;M&lt;/CODE&gt;. Check if that is correctly used in your search. &lt;BR /&gt;
Second, check if the field extraction for shutdown_date and shutdown_time is not adding additional spaces in the values, though they won't be visible in the table visualization in Splunk but will mess up your time conversion. If possible share the regular expression used for the extraction.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:11:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255666#M189492</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T09:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255667#M189493</link>
      <description>&lt;P&gt;Try the solution from my answer below - this should work!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 11:15:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255667#M189493</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2016-03-23T11:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: converting to an epoch date format using strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255668#M189494</link>
      <description>&lt;P&gt;you were correct about the field extraction. The problem was hidden characters or spaces. I changed the regex and the date fields now convert without issue. thanks again for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 11:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-to-an-epoch-date-format-using-strptime/m-p/255668#M189494</guid>
      <dc:creator>pc1234</dc:creator>
      <dc:date>2016-03-23T11:44:47Z</dc:date>
    </item>
  </channel>
</rss>

