<?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: Converting date to epoch time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316928#M94816</link>
    <description>&lt;P&gt;I can't seem to get the above snippet to change my Ephoch timestamp column to readable date - what am I doing wrong:&lt;/P&gt;

&lt;P&gt;(index="wsecu_apps" OR index="wsecu_mobile_app") (username="&lt;EM&gt;" AND Useragent="&lt;/EM&gt;" AND http_method=POST) OR (username="&lt;EM&gt;" AND http_user_agent="&lt;/EM&gt;") | table username, http_user_agent, Useragent, eval timestamp = strptime(timestamp, "%m/%d/%Y %H:%M"),I'm still getting strangness.&lt;/P&gt;

&lt;P&gt;Here is my query, the "timestamp" column is in the Epoch time and I just wanted to convert it to readable date:&lt;BR /&gt;
(index="wsecu_apps" OR index="wsecu_mobile_app") (username="&lt;EM&gt;" AND Useragent="&lt;/EM&gt;" AND http_method=POST) OR (username="&lt;EM&gt;" AND http_user_agent="&lt;/EM&gt;") | table username, http_user_agent, Useragent, eval timestamp = strptime(timestamp, "%m/%d/%Y %H:%M")&lt;/P&gt;

&lt;P&gt;The query won't even run.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:06:28 GMT</pubDate>
    <dc:creator>hortoristic</dc:creator>
    <dc:date>2020-09-30T02:06:28Z</dc:date>
    <item>
      <title>Converting date to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316924#M94812</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I'm trying to convert a certain date to epoch time to calculate it with the current time. But for some reason it didn't work.&lt;/P&gt;

&lt;P&gt;Here's my query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sample_data" sourcetype="management_sampledata.csv" Status!=Closed
| eval reported_date = strptime("Reported Date", "%m/%d/%Y %H:%M")
| eval timenow = now()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;eval timenow = now()&lt;/CODE&gt; worked and it created a new field named "timenow". But the &lt;CODE&gt;eval reported_date=strptime("Reported Date", "%m/%d/%Y %H:%M")&lt;/CODE&gt; didn't work. It does not create a new field named "reported_date" and so it did not convert the "Reported Date" to epoch time.&lt;/P&gt;

&lt;P&gt;What could be the problem with this query.&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 09:20:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316924#M94812</guid>
      <dc:creator>jvmerilla</dc:creator>
      <dc:date>2017-12-01T09:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316925#M94813</link>
      <description>&lt;P&gt;Hi @jvmerilla,&lt;/P&gt;

&lt;P&gt;You are facing problem because there is whitespace in your Date field name you are giving it in &lt;CODE&gt;"&lt;/CODE&gt; in &lt;CODE&gt;strptime&lt;/CODE&gt; so please use below query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="sample_data" sourcetype="management_sampledata.csv" Status!=Closed
| rename "Reported Date" AS Reported_Date
| eval reported_date = strptime(Reported_Date, "%m/%d/%Y %H:%M")
| eval timenow = now()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this helps.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 09:28:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316925#M94813</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-12-01T09:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316926#M94814</link>
      <description>&lt;P&gt;Hi @harsmarvania57,&lt;/P&gt;

&lt;P&gt;It works!&lt;/P&gt;

&lt;P&gt;Thank you so much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 09:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316926#M94814</guid>
      <dc:creator>jvmerilla</dc:creator>
      <dc:date>2017-12-01T09:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316927#M94815</link>
      <description>&lt;P&gt;You can use as it is:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index="sample_data" sourcetype="management_sampledata.csv" Status!=Closed&lt;BR /&gt;
 | eval reported_date = strptime('Reported Date', "%m/%d/%Y %H:%M")&lt;BR /&gt;
 | eval timenow = now()&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Just need to use single quotes instead of double quotes.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2017 08:00:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316927#M94815</guid>
      <dc:creator>dsiob</dc:creator>
      <dc:date>2017-12-21T08:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316928#M94816</link>
      <description>&lt;P&gt;I can't seem to get the above snippet to change my Ephoch timestamp column to readable date - what am I doing wrong:&lt;/P&gt;

&lt;P&gt;(index="wsecu_apps" OR index="wsecu_mobile_app") (username="&lt;EM&gt;" AND Useragent="&lt;/EM&gt;" AND http_method=POST) OR (username="&lt;EM&gt;" AND http_user_agent="&lt;/EM&gt;") | table username, http_user_agent, Useragent, eval timestamp = strptime(timestamp, "%m/%d/%Y %H:%M"),I'm still getting strangness.&lt;/P&gt;

&lt;P&gt;Here is my query, the "timestamp" column is in the Epoch time and I just wanted to convert it to readable date:&lt;BR /&gt;
(index="wsecu_apps" OR index="wsecu_mobile_app") (username="&lt;EM&gt;" AND Useragent="&lt;/EM&gt;" AND http_method=POST) OR (username="&lt;EM&gt;" AND http_user_agent="&lt;/EM&gt;") | table username, http_user_agent, Useragent, eval timestamp = strptime(timestamp, "%m/%d/%Y %H:%M")&lt;/P&gt;

&lt;P&gt;The query won't even run.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:06:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-date-to-epoch-time/m-p/316928#M94816</guid>
      <dc:creator>hortoristic</dc:creator>
      <dc:date>2020-09-30T02:06:28Z</dc:date>
    </item>
  </channel>
</rss>

