<?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: How to transform a string (i.e. 11-MAY-2017) to a date field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353539#M104640</link>
    <description>&lt;P&gt;Just to add to this....I want the value to be numeric so I can sort it.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2017 14:43:40 GMT</pubDate>
    <dc:creator>AJNZAZ</dc:creator>
    <dc:date>2017-09-21T14:43:40Z</dc:date>
    <item>
      <title>How to transform a string (i.e. 11-MAY-2017) to a date field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353538#M104639</link>
      <description>&lt;P&gt;I have two fields START and END that are tagged as strings.  The two fields always carry a value in the format dd-[3-letter MONTH-yyyy. As an example:&lt;/P&gt;

&lt;P&gt;START=07-SEP-2017 &lt;BR /&gt;
END=11-NOV-2045&lt;/P&gt;

&lt;P&gt;I have gone through and applied solutions provided in previous posts to no avail. I have tried using regex or eval and strptime commands unsuccessfully while attempting to convert the date format 14-JUN-2017 to a date field.  my most recent update was to use Index=* sourcetype=* | eval -START=strptime(START, %d-%b-%Y).  Has anyone come across this 'specific' format and issue before?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 14:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353538#M104639</guid>
      <dc:creator>AJNZAZ</dc:creator>
      <dc:date>2017-09-21T14:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform a string (i.e. 11-MAY-2017) to a date field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353539#M104640</link>
      <description>&lt;P&gt;Just to add to this....I want the value to be numeric so I can sort it.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 14:43:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353539#M104640</guid>
      <dc:creator>AJNZAZ</dc:creator>
      <dc:date>2017-09-21T14:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform a string (i.e. 11-MAY-2017) to a date field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353540#M104641</link>
      <description>&lt;P&gt;There may be a syntax issue with the way you used strptime, but can't say for sure as you didn't format the query portion using code formatter (101010 button on top of the editor OR Ctrl+K after selecting text). Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourIndex sourcetype=yourSourcetype | eval START=strptime(START,"%d-%b-%Y")  | eval END=strptime(END,"%d-%b-%Y") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 14:49:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353540#M104641</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-21T14:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform a string (i.e. 11-MAY-2017) to a date field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353541#M104642</link>
      <description>&lt;P&gt;I think I figured it out. This is the syntax I used:&lt;/P&gt;

&lt;P&gt;index=NAME sourcetype=NAME | eval START_TIME=strftime(strptime(START, "%d-%b-%Y"), "%m/%d/%y") | | eval END_TIME=strftime(strptime(END, "%d-%b-%Y"), "%m/%d/%y")&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:54:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353541#M104642</guid>
      <dc:creator>AJNZAZ</dc:creator>
      <dc:date>2020-09-29T15:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to transform a string (i.e. 11-MAY-2017) to a date field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353542#M104643</link>
      <description>&lt;P&gt;Hi AJNZAZ,&lt;BR /&gt;
could you detail your problem?&lt;BR /&gt;
I checked strptime with your format and it runs, you can use these fields in epochtime for calculations (e.g. difference):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal 
| head 1 
| eval START="07-SEP-2017", END="11-NOV-2045", START=strptime(START,"%d-%b-%Y"), END=strptime(END,"%d-%b-%Y"), END=strptime(END,"%d-%b-%Y"), DIFF=tostring(END-START,"duration") 
| table START END DIFF
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;START   END DIFF
1504735200.000000   2393967600.000000   10292+01:00:00.000000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 14:57:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-a-string-i-e-11-MAY-2017-to-a-date-field/m-p/353542#M104643</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-21T14:57:49Z</dc:date>
    </item>
  </channel>
</rss>

