<?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: fieldformat not working? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191205#M55046</link>
    <description>&lt;P&gt;Nope, this still doesn't work for me. The Time field is empty (no content at all).&lt;BR /&gt;
If I put fieldformat Time=strftime(_time ...) then sorting doesn't work.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Dec 2013 10:23:42 GMT</pubDate>
    <dc:creator>bojanz</dc:creator>
    <dc:date>2013-12-30T10:23:42Z</dc:date>
    <item>
      <title>fieldformat not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191203#M55044</link>
      <description>&lt;P&gt;I'm using fieldformat (Splunk 5.0.5, search head in a cluster, if that matters) in order to change how the time is displayed and to preserve proper sorting in tables, however it appears that it does not work correctly at all (sorting still fails).&lt;/P&gt;

&lt;P&gt;Here's what I'm doing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=windows source="wineventlog:security" "EventCode=644" OR "EventCode=4740" | fieldformat Time=strftime(_time, "%d.%m.%Y %H:%M:%S") | table _time Time host Account_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This displays a table that uses both the original _time and Time. The Time variable is properly displayed but sorting by it fails.&lt;/P&gt;

&lt;P&gt;If I do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=windows source="wineventlog:security" "EventCode=644" OR "EventCode=4740" | fieldformat _time=strftime(_time, "%d.%m.%Y %H:%M:%S") | table _time host Account_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then time is completely lost and all entries show as 1/1/01 12:00:00.000 AM.&lt;/P&gt;

&lt;P&gt;Any clues?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2013 19:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191203#M55044</guid>
      <dc:creator>bojanz</dc:creator>
      <dc:date>2013-12-27T19:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: fieldformat not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191204#M55045</link>
      <description>&lt;P&gt;&lt;CODE&gt;fieldformat&lt;/CODE&gt; creates a representation (usually a string) for a field that is independent of its underlying value. The &lt;CODE&gt;_time&lt;/CODE&gt; field is an internal field, and it cannot have such a representation.&lt;/P&gt;

&lt;P&gt;Your first search gives you a representation for &lt;CODE&gt;Time&lt;/CODE&gt; but not an underlying value that is sortable; it is simply a string. That is why it doesn't sort properly.&lt;/P&gt;

&lt;P&gt;Your second search attempts to assign a string representation to the internal variable &lt;CODE&gt;_time&lt;/CODE&gt;; this doesn't work.&lt;/P&gt;

&lt;P&gt;To get what you want, try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=windows source="wineventlog:security" EventCode=644 OR EventCode=4740 
| eval Time=_time
| fieldformat Time=strftime(Time, "%d.%m.%Y %H:%M:%S") 
| table Time host Account_Name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 28 Dec 2013 18:31:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191204#M55045</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-12-28T18:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: fieldformat not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191205#M55046</link>
      <description>&lt;P&gt;Nope, this still doesn't work for me. The Time field is empty (no content at all).&lt;BR /&gt;
If I put fieldformat Time=strftime(_time ...) then sorting doesn't work.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2013 10:23:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191205#M55046</guid>
      <dc:creator>bojanz</dc:creator>
      <dc:date>2013-12-30T10:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: fieldformat not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191206#M55047</link>
      <description>&lt;P&gt;Sorry, there was a typo in my answer. I then tested this on my Splunk and it works.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2013 18:17:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191206#M55047</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-12-31T18:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: fieldformat not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191207#M55048</link>
      <description>&lt;P&gt;index=windows source="wineventlog:security" "EventCode=644" OR "EventCode=4740" | eval Time=strftime(_time, "%d.%m.%Y %H:%M:%S")|fields - _time| sort + Time | table Time host Account_Name&lt;/P&gt;

&lt;P&gt;Works in Splunk 6, not sure where the sorting fails!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:33:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fieldformat-not-working/m-p/191207#M55048</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2020-09-28T15:33:37Z</dc:date>
    </item>
  </channel>
</rss>

