<?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: Difficult date time conversion in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92342#M23839</link>
    <description>&lt;P&gt;I see - I would not have caught that. But your sed/regex works great. Thanks very much!&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jan 2013 15:11:30 GMT</pubDate>
    <dc:creator>timbitsandbytes</dc:creator>
    <dc:date>2013-01-21T15:11:30Z</dc:date>
    <item>
      <title>Difficult date time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92338#M23835</link>
      <description>&lt;P&gt;Well it's a difficult conversion for me, anyway.&lt;/P&gt;

&lt;P&gt;Here's the field: dateTime=Fri Jan 18 17:11:55 GMT+00:00 2013&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I want to convert it to seconds since the epoch so I can do a date comparison.&lt;/LI&gt;
&lt;LI&gt;I don't think there's a way for Splunk to recognize the tz offset as "+00:00" so first I transform that to "+0000".&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;eval dtFormatted=replace(dateTime, ":", "") |&lt;BR /&gt;
eval dtSeconds=strptime(dtFormatted, "%a %b %d %H%M%S %Z%:z %Y")&lt;/P&gt;

&lt;P&gt;In my search results "dtFormatted" is discovered and I've verified it's properly formatted but "dtSeconds" is not discovered. &lt;/P&gt;

&lt;P&gt;What am I doing wrong? Why can't I convert this string to seconds?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2013 17:38:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92338#M23835</guid>
      <dc:creator>timbitsandbytes</dc:creator>
      <dc:date>2013-01-18T17:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Difficult date time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92339#M23836</link>
      <description>&lt;P&gt;Shouldn't you have dtFormatted as the 1st argument to strptime ?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2013 18:08:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92339#M23836</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-01-18T18:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Difficult date time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92340#M23837</link>
      <description>&lt;P&gt;Yes, thanks. Unfortunately when I copied the search string (on a network that doesn't have access to the Internet) I miscopied it. It's been corrected above.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2013 18:26:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92340#M23837</guid>
      <dc:creator>timbitsandbytes</dc:creator>
      <dc:date>2013-01-18T18:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Difficult date time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92341#M23838</link>
      <description>&lt;P&gt;Try this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex mode=sed field=dateTime "s/(\+[0-9:]{5})/ \1/" 
    | eval dtSeconds=strptime(dateTime, "%a %b %d %T %Z %:z %Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem was that %Z expects a space after the time zone, In your format %Z was being set to GMT+0000 instead of GMT, and %Y was null.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2013 10:46:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92341#M23838</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-01-19T10:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Difficult date time conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92342#M23839</link>
      <description>&lt;P&gt;I see - I would not have caught that. But your sed/regex works great. Thanks very much!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2013 15:11:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difficult-date-time-conversion/m-p/92342#M23839</guid>
      <dc:creator>timbitsandbytes</dc:creator>
      <dc:date>2013-01-21T15:11:30Z</dc:date>
    </item>
  </channel>
</rss>

