<?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: extract a string into readable datetime format in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119607#M32105</link>
    <description>&lt;P&gt;Not sure why the string is not extracted in human readable, but if you use ctime on the created epoch time it should work.&lt;BR /&gt;
&lt;CODE&gt;eval newdate="20140120.1815"|eval time=strptime(newdate,"%Y%m%d.%H%M")|convert timeformat="%Y%m%d.%H%M" ctime(time) as Time | table Time&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2014 13:45:42 GMT</pubDate>
    <dc:creator>lukejadamec</dc:creator>
    <dc:date>2014-01-21T13:45:42Z</dc:date>
    <item>
      <title>extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119604#M32102</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
I have string  in a format as "YYYYMMDD.HHMM" i.e. 20140120.1815&lt;/P&gt;

&lt;P&gt;I want to display this in any readable date time format which splunk understands as I have to do further analysis on the basis of time to show it on chart.&lt;/P&gt;

&lt;P&gt;Kindly help&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2014 12:49:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119604#M32102</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2014-01-20T12:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119605#M32103</link>
      <description>&lt;P&gt;&lt;CODE&gt;eval time=strptime(&amp;lt;time string&amp;gt;,"%Y%m%d.%H%M")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2014 13:05:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119605#M32103</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-01-20T13:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119606#M32104</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have tried it, but couldn't able to get proper result.&lt;BR /&gt;
My query is as below:&lt;/P&gt;

&lt;P&gt;eval newdate="20140120.1815"|eval time=strptime(newdate,"%Y%m%d.%H%M")|table time&lt;/P&gt;

&lt;P&gt;it shows output as:   1390221900.000000&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2014 10:37:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119606#M32104</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2014-01-21T10:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119607#M32105</link>
      <description>&lt;P&gt;Not sure why the string is not extracted in human readable, but if you use ctime on the created epoch time it should work.&lt;BR /&gt;
&lt;CODE&gt;eval newdate="20140120.1815"|eval time=strptime(newdate,"%Y%m%d.%H%M")|convert timeformat="%Y%m%d.%H%M" ctime(time) as Time | table Time&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2014 13:45:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119607#M32105</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2014-01-21T13:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119608#M32106</link>
      <description>&lt;P&gt;This should work for you&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | head 1 | eval newdate="20140120.1815"| table newdate|eval time=strptime(newdate,"%Y%m%d.%H%M") | eval Time=strftime(time,"%Y-%m-%d %H:%M:%S.%3Q %p")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2014 14:19:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119608#M32106</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-01-21T14:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119609#M32107</link>
      <description>&lt;P&gt;My answer is pretty much the same but you can combine strptime with strftime like this:&lt;/P&gt;

&lt;P&gt;| eval newdate="20140120.1815" | eval time=strftime(strptime(newdate,"%Y%m%d.%H%M"),"%Y-%m-%d %T") | table time&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;output is:&lt;/STRONG&gt; 2014-01-20 18:15:00&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;strptime()&lt;/STRONG&gt; - converts your string into a timestamp (epoch or 'seconds since Thursday, 1 January 1970')&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;strftime()&lt;/STRONG&gt; - converts epoch timestamp into the viewable format of your deepest desire&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;see time variables:&lt;/STRONG&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/Commontimeformatvariables"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;see functions for eval / where:&lt;/STRONG&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2014 18:35:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119609#M32107</guid>
      <dc:creator>jpass</dc:creator>
      <dc:date>2014-01-21T18:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119610#M32108</link>
      <description>&lt;P&gt;Thanks somesoni2..&lt;BR /&gt;
This worked like a charm&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2014 05:52:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119610#M32108</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2014-01-23T05:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119611#M32109</link>
      <description>&lt;P&gt;Perfect! I had to convert the Date variable of this format Wed Feb 05 UTC 2014 to 2014-02-05.I used the above command like this-&lt;BR /&gt;
eval time=strptime(Date,"%a %b %d UTC %Y") | eval Time=strftime(time,"%Y-%m-%d")|&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2014 20:21:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119611#M32109</guid>
      <dc:creator>arya_alex</dc:creator>
      <dc:date>2014-02-07T20:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: extract a string into readable datetime format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119612#M32110</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;

&lt;P&gt;I cannot make it work, I have this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | head 1  | eval my_time="Sun Apr 30 23:46:53 GMT+00:00 2017" | table my_time | eval final=strptime(my_time, "%a %b %d %H:%M:%S %Z%z %Y") | eval Time=strftime(time,"%Y-%m-%d %H:%M:%S") | table my_time,final,Time 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have to fields, StartTime and EndTime and I want to measure the difference between them. But I'm not getting even a timestamp conversion for one field.&lt;/P&gt;

&lt;P&gt;Help please!&lt;BR /&gt;
Thanks&lt;/P&gt;

&lt;P&gt;PD: I think I don't have the epoch time neither. So my first problem is there &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 09:51:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-a-string-into-readable-datetime-format/m-p/119612#M32110</guid>
      <dc:creator>marina_rovira</dc:creator>
      <dc:date>2017-05-18T09:51:40Z</dc:date>
    </item>
  </channel>
</rss>

