<?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: Convert timestamp at search time for report? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-at-search-time-for-report/m-p/91447#M23527</link>
    <description>&lt;P&gt;Are you &lt;EM&gt;really sure&lt;/EM&gt; it's still the same format? &lt;/P&gt;

&lt;P&gt;Your sample looks like it would convert to unix epoch time, but would still give you a numeric result. It would look very similar (especially because of the milliseconds at the end) but it would start with a number around '1290' instead of '2010'.&lt;/P&gt;

&lt;P&gt;You should be able to just do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval Call_Start_Time = strptime(Start_Time, "%Y%m%d%H%M%S.%q")
| convert mktime(Start_Time)
| stats list(Call_Start_Time) by Calling_Number
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want another test search, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | head 1 | eval Start_Time="20101117201236.368"
| eval Call_Start_Time = strptime(Start_Time, "%Y%m%d%H%M%S.%q")
| eval Text_Start_Time=Call_Start_Time
| convert ctime(Text_Start_Time)
| table Start_Time, Call_Start_Time, Text_Start_Time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should produce the following table, with &lt;CODE&gt;Start_Time&lt;/CODE&gt; containing the sample string you provided, &lt;CODE&gt;Call_Start_Time&lt;/CODE&gt; containing the equivalent time in unix epoch format, and &lt;CODE&gt;Text_Start_Time&lt;/CODE&gt; containing a human-readable version:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Start_Time             Call_Start_Time       Text_Start_Time 
20101117201236.368     1290042756.368000     11/17/2010 20:12:36.368000
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 18 Nov 2010 06:54:15 GMT</pubDate>
    <dc:creator>southeringtonp</dc:creator>
    <dc:date>2010-11-18T06:54:15Z</dc:date>
    <item>
      <title>Convert timestamp at search time for report?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-at-search-time-for-report/m-p/91446#M23526</link>
      <description>&lt;P&gt;Hey everyone!
I am working on files right now that contain numerous timestamps. The timestamps are presented in this fashion: 20101117201236.368 (YYYYMMDDHHMMSS.SSSS). I have managed to get time stamp extraction working properly, so the events are getting the correct timestamp. However when I attempt to generate the date and time in a report I still get the original format for the data. How can I do this in a search string? I've tried using this format but its not working. Any ideas?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval Call_Start_Time = strptime(Start_Time, "%Y%m%d%H%M%S.%q") |stats list(Call_Start_Time) by Calling_Number
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Nov 2010 05:04:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-at-search-time-for-report/m-p/91446#M23526</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2010-11-18T05:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert timestamp at search time for report?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-at-search-time-for-report/m-p/91447#M23527</link>
      <description>&lt;P&gt;Are you &lt;EM&gt;really sure&lt;/EM&gt; it's still the same format? &lt;/P&gt;

&lt;P&gt;Your sample looks like it would convert to unix epoch time, but would still give you a numeric result. It would look very similar (especially because of the milliseconds at the end) but it would start with a number around '1290' instead of '2010'.&lt;/P&gt;

&lt;P&gt;You should be able to just do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval Call_Start_Time = strptime(Start_Time, "%Y%m%d%H%M%S.%q")
| convert mktime(Start_Time)
| stats list(Call_Start_Time) by Calling_Number
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want another test search, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | head 1 | eval Start_Time="20101117201236.368"
| eval Call_Start_Time = strptime(Start_Time, "%Y%m%d%H%M%S.%q")
| eval Text_Start_Time=Call_Start_Time
| convert ctime(Text_Start_Time)
| table Start_Time, Call_Start_Time, Text_Start_Time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should produce the following table, with &lt;CODE&gt;Start_Time&lt;/CODE&gt; containing the sample string you provided, &lt;CODE&gt;Call_Start_Time&lt;/CODE&gt; containing the equivalent time in unix epoch format, and &lt;CODE&gt;Text_Start_Time&lt;/CODE&gt; containing a human-readable version:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Start_Time             Call_Start_Time       Text_Start_Time 
20101117201236.368     1290042756.368000     11/17/2010 20:12:36.368000
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Nov 2010 06:54:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-at-search-time-for-report/m-p/91447#M23527</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-11-18T06:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert timestamp at search time for report?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-at-search-time-for-report/m-p/91448#M23528</link>
      <description>&lt;P&gt;I got it working based on your reply! Thanks so much. Here's what I ended up doing:&lt;BR /&gt;
|eval Call_Start_Time_Text = strptime(Start_Time,"%Y%m%d%H%M%S.%q") &lt;BR /&gt;
|convert ctime(Call_Start_Time_Text)&lt;BR /&gt;
|eval Call_Release_Time_Text= strptime(Release_Time,"%Y%m%d%H%M%S.%q") &lt;BR /&gt;
|convert ctime(Call_Release_Time_Text)&lt;BR /&gt;
|eval Call_Answer_Time_Text= strptime(Answer_Time,"%Y%m%d%H%M%S.%q") &lt;BR /&gt;
|convert ctime(Call_Answer_Time_Text)&lt;/P&gt;

&lt;P&gt;If it would be possible to skip the convert operation that would be awesome, but for now its working and I can worry about cleaning it up later. Much appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:21:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-at-search-time-for-report/m-p/91448#M23528</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2020-09-28T09:21:11Z</dc:date>
    </item>
  </channel>
</rss>

