<?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 Issue with strptime in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22146#M3755</link>
    <description>&lt;P&gt;I am trying to reformat a date field in Splunk. I have a field called "last_updated_date" and its value is 2012-04-03.&lt;/P&gt;

&lt;P&gt;I am using the strptime command to reformat the field to the following: 04/03/12.&lt;BR /&gt;
Here is my syntax: &lt;BR /&gt;
   eval last_updated_date=strftime(strptime(last_updated_date,"%Y-%b-%D"),"%M/%D/%Y")&lt;/P&gt;

&lt;P&gt;However, it returns blank values in my output.&lt;/P&gt;

&lt;P&gt;Thoughts?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 11:38:53 GMT</pubDate>
    <dc:creator>efelder0</dc:creator>
    <dc:date>2020-09-28T11:38:53Z</dc:date>
    <item>
      <title>Issue with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22146#M3755</link>
      <description>&lt;P&gt;I am trying to reformat a date field in Splunk. I have a field called "last_updated_date" and its value is 2012-04-03.&lt;/P&gt;

&lt;P&gt;I am using the strptime command to reformat the field to the following: 04/03/12.&lt;BR /&gt;
Here is my syntax: &lt;BR /&gt;
   eval last_updated_date=strftime(strptime(last_updated_date,"%Y-%b-%D"),"%M/%D/%Y")&lt;/P&gt;

&lt;P&gt;However, it returns blank values in my output.&lt;/P&gt;

&lt;P&gt;Thoughts?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:38:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22146#M3755</guid>
      <dc:creator>efelder0</dc:creator>
      <dc:date>2020-09-28T11:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22147#M3756</link>
      <description>&lt;P&gt;you wrote "strftime"&lt;BR /&gt;
is that the right command?&lt;BR /&gt;
strftime takes (X) as epoch time and converts it to format Y&lt;/P&gt;

&lt;P&gt;you dont have epoch time anywhere in your syntax. epoch is # of sec since jan 1 1970 00:00:00 UTC&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.1/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/4.3.1/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 15:30:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22147#M3756</guid>
      <dc:creator>cvajs</dc:creator>
      <dc:date>2012-04-09T15:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22148#M3757</link>
      <description>&lt;P&gt;so, maybe strptime would not be useful in this scenario?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 15:40:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22148#M3757</guid>
      <dc:creator>efelder0</dc:creator>
      <dc:date>2012-04-09T15:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22149#M3758</link>
      <description>&lt;P&gt;I am looking to reformat the date to MM/DD/YYYY. Should this be done in props instead?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 15:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22149#M3758</guid>
      <dc:creator>efelder0</dc:creator>
      <dc:date>2012-04-09T15:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22150#M3759</link>
      <description>&lt;P&gt;i think SEDCMD is a better route&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 16:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22150#M3759</guid>
      <dc:creator>cvajs</dc:creator>
      <dc:date>2012-04-09T16:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with strptime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22151#M3760</link>
      <description>&lt;P&gt;There's (at least) two ways of dealing with this.  If you want to change the raw data within the event &lt;STRONG&gt;as it is being indexed&lt;/STRONG&gt; then as cvajs suggested, &lt;CODE&gt;SEDCMD&lt;/CODE&gt; is the route to take.  It would look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
SEDCMD-date=s/\d{2}(\d{2})-(\d{2})-(\d{2})/\2\/\3\/\1/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Assuming I got my sed syntax 100% correct)&lt;/P&gt;

&lt;P&gt;Your &lt;CODE&gt;strftime&lt;/CODE&gt; + &lt;CODE&gt;strptime&lt;/CODE&gt; approach should work as well.  It obviously does not change the data in the index, but it should update the field correctly.  But, I think you have your format strings wrong:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval last_updated_date=strftime(strptime(last_updated_date,"%Y-%m-%d"),"%m/%d/%y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Apr 2012 18:27:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-strptime/m-p/22151#M3760</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2012-04-09T18:27:04Z</dc:date>
    </item>
  </channel>
</rss>

