<?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: Date and time conversion in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Date-and-time-conversion/m-p/582059#M202751</link>
    <description>&lt;P&gt;Yes, you are. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;ctime expects an epoch which _time is and your body.timestamp is not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fear not as you can change that with strptime. Also you need to rename the field to something without "." as some things do not with with . on field names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval body.timestamp="2022-01-20T21:38:45.7774493Z"
| rename "body.timestamp" AS timestamp2
| eval timestamp2 = strptime(timestamp2,"%Y-%m-%dT%H:%M:%S.%7NZ")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After this you can use ctime or strftime to format the timestamp to what you want.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jan 2022 17:18:31 GMT</pubDate>
    <dc:creator>diogofgm</dc:creator>
    <dc:date>2022-01-21T17:18:31Z</dc:date>
    <item>
      <title>Date and time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-and-time-conversion/m-p/582053#M202748</link>
      <description>&lt;P&gt;Hi, in my index I have a couple time fields that are returned via a simple search&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;_time = 1/20/2022 1:38:55.000 PM (the Splunk-generated time)&lt;/LI&gt;&lt;LI&gt;body.timestamp = 2022-01-20T21:38:45.7774493Z (the transaction time from our log)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I am trying to format the time output with the convert function but can only get the first result to return.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(_time) AS timestamp = 2022-01-20 21:38:55&lt;BR /&gt;| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(body.timestamp) AS timestamp2 = none&lt;/P&gt;&lt;P&gt;Am I missing something for the second timestamp to be returned? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:51:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-and-time-conversion/m-p/582053#M202748</guid>
      <dc:creator>nate_washburn</dc:creator>
      <dc:date>2022-01-21T16:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Date and time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-and-time-conversion/m-p/582059#M202751</link>
      <description>&lt;P&gt;Yes, you are. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;ctime expects an epoch which _time is and your body.timestamp is not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fear not as you can change that with strptime. Also you need to rename the field to something without "." as some things do not with with . on field names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval body.timestamp="2022-01-20T21:38:45.7774493Z"
| rename "body.timestamp" AS timestamp2
| eval timestamp2 = strptime(timestamp2,"%Y-%m-%dT%H:%M:%S.%7NZ")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After this you can use ctime or strftime to format the timestamp to what you want.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 17:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-and-time-conversion/m-p/582059#M202751</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2022-01-21T17:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Date and time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Date-and-time-conversion/m-p/582078#M202756</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/90723"&gt;@diogofgm&lt;/a&gt;&amp;nbsp; you got me started down the correct path.&amp;nbsp; With a little tweeking, here is what worked for me.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval body.timestamp=strptime('body.timestamp',"%Y-%m-%dT%H:%M:%S.%7NZ")
| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(body.timestamp) as timestamp2&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Jan 2022 18:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Date-and-time-conversion/m-p/582078#M202756</guid>
      <dc:creator>nate_washburn</dc:creator>
      <dc:date>2022-01-21T18:19:45Z</dc:date>
    </item>
  </channel>
</rss>

