<?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 convert a timestamp field to epoch format? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191349#M38080</link>
    <description>&lt;P&gt;You could do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search identifying the correct file | eval dateadded_epoch = strptime('Date Added', "%Y-%m-%d %H:%S") | where dateadded_epoch &amp;gt;= relative_time(now(), "-7d@d")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 02 Nov 2014 16:27:06 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-11-02T16:27:06Z</dc:date>
    <item>
      <title>How to convert a timestamp field to epoch format?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191348#M38079</link>
      <description>&lt;P&gt;I'm loading a file via Data Inputs into Splunk on a daily basis. When I load the file the _time field is the current time when the file is loaded and the 'Date Added' is the time a device was added.&lt;/P&gt;

&lt;P&gt;My goal is to be able to search based on time for both of these specific fields. For example, the files will be loaded on a daily basis so I want to be able to look at the logs from only the last file loaded at any given time. Then once I find the logs for that file I want to be able to search those logs for any that have a 'Date Added' date that is -7d@d.&lt;/P&gt;

&lt;P&gt;My problem is I can't seem to figure out how to convert the 'Date Added' field into a time based field so I can search off of it? Is this possible?&lt;/P&gt;

&lt;P&gt;Below is what the log looks like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                                          Date Added
10/29/14 3:42:00.000 PM "Test-Machine"," "," ","2014-10-29 15:42"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Nov 2014 14:51:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191348#M38079</guid>
      <dc:creator>akelly4</dc:creator>
      <dc:date>2014-11-02T14:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a timestamp field to epoch format?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191349#M38080</link>
      <description>&lt;P&gt;You could do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search identifying the correct file | eval dateadded_epoch = strptime('Date Added', "%Y-%m-%d %H:%S") | where dateadded_epoch &amp;gt;= relative_time(now(), "-7d@d")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Nov 2014 16:27:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191349#M38080</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-11-02T16:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a timestamp field to epoch format?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191350#M38081</link>
      <description>&lt;P&gt;Another way to make epoch time without making new field,&lt;/P&gt;

&lt;P&gt;same query instead of &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval dateadded_epoch = strptime('Date Added', "%Y-%m-%d %H:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| convert timeformat="%Y-%m-%d %H:%M:%S" mktime("Date Added")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Query&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;base search identifying the correct file  | convert timeformat="%Y-%m-%d %H:%M:%S" mktime("Date Added") | where "Date Added" &amp;gt;= relative_time(now(), "-7d@d")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;At end you will get same result &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Vasu&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2014 05:39:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191350#M38081</guid>
      <dc:creator>vasanthmss</dc:creator>
      <dc:date>2014-11-04T05:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a timestamp field to epoch format?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191351#M38082</link>
      <description>&lt;P&gt;Splunk already has a field for when data is added (or indexed to be more accurate) _indextime. You could flip this around and set _time at index time to be the value of Date Added, have a look at props.conf to set this up;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/Admin/Propsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/Admin/Propsconf&lt;/A&gt;&lt;BR /&gt;
Its pretty straightforward and your date format should be understood without issue.&lt;BR /&gt;
This way you can then search by _indextime and _time, although if you want the performance boost of filtering on _time with the expectation that this is the date added, then this option isn't for you.,Just to throw another option out there, Splunk already has a time field for when data is added - _indextime. So why not just override _time to be Date Added at index time?&lt;BR /&gt;
Have a look through &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/Admin/Propsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/Admin/Propsconf&lt;/A&gt; for all the options but its pretty simple to configure and you may find it a better solution in the long run.&lt;/P&gt;

&lt;P&gt;If you want the performance boost of filtering on _time being the time added then this won't be for you but if you're going to search for both values, it should help.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2014 07:22:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-a-timestamp-field-to-epoch-format/m-p/191351#M38082</guid>
      <dc:creator>Drainy</dc:creator>
      <dc:date>2014-11-04T07:22:42Z</dc:date>
    </item>
  </channel>
</rss>

