<?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: Extracting date from a date string that has many options in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-date-from-a-date-string-that-has-many-options/m-p/375097#M110224</link>
    <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;P&gt;ex.)---extract the day-&amp;gt;Day&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search)|rex field=Date "^(?&amp;lt;wk_day&amp;gt;\d+)\/(?&amp;lt;wk_month&amp;gt;\d+)\/(?&amp;lt;wk_year&amp;gt;\d+)$"
| eval wk_day=if(len(wk_day)=2,wk_day,"0"+wk_day),
  wk_month=if(len(wk_month)=2,wk_month,"0"+wk_month),
  wk_year=if(len(wk_year)=4,wk_year,"20"+wk_year)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 Aug 2017 09:54:52 GMT</pubDate>
    <dc:creator>HiroshiSatoh</dc:creator>
    <dc:date>2017-08-23T09:54:52Z</dc:date>
    <item>
      <title>Extracting date from a date string that has many options</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-date-from-a-date-string-that-has-many-options/m-p/375096#M110223</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a field (string) that contains dates. the fields has a few formats and I need to extract the day, month and year from it.&lt;BR /&gt;
Examples for the values possible of that field:&lt;BR /&gt;
4/8/2016&lt;BR /&gt;
4/8/16&lt;BR /&gt;
04/8/2016&lt;BR /&gt;
04/8/16&lt;BR /&gt;
4/08/2016&lt;BR /&gt;
04/08/2016&lt;BR /&gt;
31/08/16&lt;/P&gt;

&lt;P&gt;I think regex would be a good way to solve it, but I cant figure out how to use it.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 09:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-date-from-a-date-string-that-has-many-options/m-p/375096#M110223</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-23T09:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting date from a date string that has many options</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-date-from-a-date-string-that-has-many-options/m-p/375097#M110224</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;P&gt;ex.)---extract the day-&amp;gt;Day&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search)|rex field=Date "^(?&amp;lt;wk_day&amp;gt;\d+)\/(?&amp;lt;wk_month&amp;gt;\d+)\/(?&amp;lt;wk_year&amp;gt;\d+)$"
| eval wk_day=if(len(wk_day)=2,wk_day,"0"+wk_day),
  wk_month=if(len(wk_month)=2,wk_month,"0"+wk_month),
  wk_year=if(len(wk_year)=4,wk_year,"20"+wk_year)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Aug 2017 09:54:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-date-from-a-date-string-that-has-many-options/m-p/375097#M110224</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2017-08-23T09:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting date from a date string that has many options</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-date-from-a-date-string-that-has-many-options/m-p/375098#M110225</link>
      <description>&lt;P&gt;Thanks! exactly what I needed&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 09:59:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-date-from-a-date-string-that-has-many-options/m-p/375098#M110225</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2017-08-23T09:59:19Z</dc:date>
    </item>
  </channel>
</rss>

