<?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 extract time and format using regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434161#M123933</link>
    <description>&lt;P&gt;well, once the data is indexed, we can not / should not update the timestamp "_time ". &lt;BR /&gt;
maybe, if you update us the more clear info about your issue, there can be some workaround.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Aug 2018 14:39:06 GMT</pubDate>
    <dc:creator>inventsekar</dc:creator>
    <dc:date>2018-08-29T14:39:06Z</dc:date>
    <item>
      <title>How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434156#M123928</link>
      <description>&lt;P&gt;Hello fellows, &lt;/P&gt;

&lt;P&gt;I have an issue that I'm not really sure how to solve. &lt;/P&gt;

&lt;P&gt;Well in event I have time in following format "datetime":"20180829 073501672". &lt;/P&gt;

&lt;P&gt;I have created a regex that will extract this line but now I need to format it following way 2018 08 29  07:35:01:672. &lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 11:11:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434156#M123928</guid>
      <dc:creator>ninisimonishvil</dc:creator>
      <dc:date>2018-08-29T11:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434157#M123929</link>
      <description>&lt;P&gt;Convert it into a date type variable using strptime and then format it using stftime - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearch....| eval datetimeNEW=strftime(strptime(datetime, "%Y%m%d %H%M%S%3Q"), "%Y %m %d %H:%M:%S:%3Q")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Aug 2018 11:36:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434157#M123929</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-08-29T11:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434158#M123930</link>
      <description>&lt;P&gt;Thanks it worked. however now with this, I will not be able to make _time (index time) = datetimeNEW correct? &lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 11:48:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434158#M123930</guid>
      <dc:creator>ninisimonishvil</dc:creator>
      <dc:date>2018-08-29T11:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434159#M123931</link>
      <description>&lt;P&gt;you can use _time inside the strptime command...&lt;BR /&gt;
&lt;CODE&gt;eval datetimeNEW=strftime(strptime(_time, "%Y%m%d %H%M%S%3Q"), "%Y %m %d %H:%M:%S:%3Q")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:04:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434159#M123931</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2020-09-29T21:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434160#M123932</link>
      <description>&lt;P&gt;sorry for confusion what I meant is that I don't want _time to be equal to index time (that's what splunk does right now) I want it to use my datetimeNEW as a _time. &lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 13:31:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434160#M123932</guid>
      <dc:creator>ninisimonishvil</dc:creator>
      <dc:date>2018-08-29T13:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434161#M123933</link>
      <description>&lt;P&gt;well, once the data is indexed, we can not / should not update the timestamp "_time ". &lt;BR /&gt;
maybe, if you update us the more clear info about your issue, there can be some workaround.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 14:39:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434161#M123933</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-08-29T14:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434162#M123934</link>
      <description>&lt;P&gt;one more question, how can I make a small change in my datetimnew?  something like eval eval newtime=datetimenew+4 hours?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 09:15:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434162#M123934</guid>
      <dc:creator>ninisimonishvil</dc:creator>
      <dc:date>2018-09-06T09:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434163#M123935</link>
      <description>&lt;P&gt;from Ayn's answer at - &lt;A href="https://answers.splunk.com/answers/103552/adding-seconds-to-time.html" target="_blank"&gt;https://answers.splunk.com/answers/103552/adding-seconds-to-time.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;_time is actually in epoch format, Splunk just converts the format automatically before showing it to you so that it's human readable. So, to add 4 seconds, just do eval _time=_time+4.&lt;/P&gt;

&lt;P&gt;Note that this is purely a search-time operation - if you want to do this at index-time the problem is much more complex because functions for performing arithmetic etc are not available.&lt;/P&gt;

&lt;P&gt;so, do the strptime/strftime conversions after adding the 4hrs to _time..&lt;BR /&gt;
you can easily add 4 hours to _time like - &lt;BR /&gt;
&lt;CODE&gt;eval _time=_time+14400&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:09:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434163#M123935</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2020-09-29T21:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434164#M123936</link>
      <description>&lt;P&gt;thank, I did that, but however not getting results. &lt;BR /&gt;
with eval newtime=datetimenew I see new field newtime in list but as soon as I add &lt;BR /&gt;
eval newtime=datetimenew+14400 no results. &lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 10:13:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434164#M123936</guid>
      <dc:creator>ninisimonishvil</dc:creator>
      <dc:date>2018-09-06T10:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434165#M123937</link>
      <description>&lt;P&gt;check these...&lt;BR /&gt;
    | eval newtime=_time+14400&lt;BR /&gt;
    | eval datetimeNEW=strftime(strptime(newtime, "%Y%m%d %H%M%S%3Q"), "%Y %m %d %H:%M:%S:%3Q")&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;or

| eval datetimenew_epoch = strptime('datetimenew', "%Y %m %d %H:%M:%S:%3Q")
| eval datetimeAdded = datetimenew_epoch + 14400
| eval datetimeResult = strftime(datetimeAdded,  "%Y %m %d %H:%M:%S:%3Q")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Sep 2018 10:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434165#M123937</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-09-06T10:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time and format using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434166#M123938</link>
      <description>&lt;P&gt;yes thanks! I just messed up with parentheses. &lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 13:09:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-time-and-format-using-regex/m-p/434166#M123938</guid>
      <dc:creator>ninisimonishvil</dc:creator>
      <dc:date>2018-09-06T13:09:57Z</dc:date>
    </item>
  </channel>
</rss>

