<?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 and mktime not generating any values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279753#M84509</link>
    <description>&lt;P&gt;I don't think you need that case statement at all. Following direct conversion works (run anywhere sample)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval time="1/1/2013 12:00 AM" | table time| eval ntime=strptime(time,"%m/%d/%Y %H:%M %p")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 25 Jul 2016 17:02:35 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-07-25T17:02:35Z</dc:date>
    <item>
      <title>strptime and mktime not generating any values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279752#M84508</link>
      <description>&lt;P&gt;I have a CSV with a date field that I want to convert to a timefield so that I can timechart it.  When I run &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ...| rename "field I want" as time | eval time = case(substr(time, 1, 2) LIKE "%/", "0"+time, 1=1, time) |  convert timeformat="%m/%e/%Y  %I:%M %p" mktime(time) |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;time ends up being always null.  When I do &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rename "field I want" as time | eval time = case(substr(time, 1, 2) LIKE "%/", "0"+time, 1=1, time) | eval ntime=strptime(time, "%m/%e/%Y  %I:%M %p") |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;ntime doesn't even get created as a field.  I'm 100% sure that the formatting is correct (though theres always a chance for errors) and I've tried everything I can think of.  Why does neither function evaluate?  An example of one of the strings I'm trying to convert is "1/1/2013 12:00 AM".&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 15:11:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279752#M84508</guid>
      <dc:creator>thyrfa</dc:creator>
      <dc:date>2016-07-25T15:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: strptime and mktime not generating any values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279753#M84509</link>
      <description>&lt;P&gt;I don't think you need that case statement at all. Following direct conversion works (run anywhere sample)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval time="1/1/2013 12:00 AM" | table time| eval ntime=strptime(time,"%m/%d/%Y %H:%M %p")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:02:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279753#M84509</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-25T17:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: strptime and mktime not generating any values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279754#M84510</link>
      <description>&lt;P&gt;Woah that worked!  The issue was me putting the table after evaluating ntime.  Why does that matter?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279754#M84510</guid>
      <dc:creator>thyrfa</dc:creator>
      <dc:date>2016-07-25T17:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: strptime and mktime not generating any values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279755#M84511</link>
      <description>&lt;P&gt;It won't. Probably the timeformat you used was the issue, along with additional formatting you were trying.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:21:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/strptime-and-mktime-not-generating-any-values/m-p/279755#M84511</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-25T17:21:37Z</dc:date>
    </item>
  </channel>
</rss>

