<?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 How to extract a date from a string? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354744#M104980</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a string &lt;BR /&gt;
'ABC_GFD_NOCS_RPT_HIST_2017-05-12_5min.csv'&lt;/P&gt;

&lt;P&gt;How do I extract '2017-05-12' from 'ABC_GFD_NOCS_RPT_HIST_2017-05-12_5min.csv' in my saved search?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:30:35 GMT</pubDate>
    <dc:creator>rmuraly</dc:creator>
    <dc:date>2020-09-29T14:30:35Z</dc:date>
    <item>
      <title>How to extract a date from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354744#M104980</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a string &lt;BR /&gt;
'ABC_GFD_NOCS_RPT_HIST_2017-05-12_5min.csv'&lt;/P&gt;

&lt;P&gt;How do I extract '2017-05-12' from 'ABC_GFD_NOCS_RPT_HIST_2017-05-12_5min.csv' in my saved search?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:30:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354744#M104980</guid>
      <dc:creator>rmuraly</dc:creator>
      <dc:date>2020-09-29T14:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354745#M104981</link>
      <description>&lt;P&gt;You might have to add mocked up raw data and also your search for us to help you better. However, based on what you have provided please try following regular expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "_(?&amp;lt;Date&amp;gt;\d{4}-\d{2}-\d{2})_"
| table Date _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 19:04:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354745#M104981</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-06-15T19:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354746#M104982</link>
      <description>&lt;P&gt;If this string is part of an already extracted field, say file_path, then in rex command, use file_path instead of _raw.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:28:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354746#M104982</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T14:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354747#M104983</link>
      <description>&lt;P&gt;I had to extract the date from my source file and this helps me do it.&lt;/P&gt;

&lt;P&gt;| stats count | eval source="ABC_GFD_NOCS_RPT_HIST_2017-05-12_5min.csv"| rex field=source"&lt;EM&gt;(?\d{4}-\d{2}-\d{2})&lt;/EM&gt;"&lt;BR /&gt;
 | table Date,source&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:30:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354747#M104983</guid>
      <dc:creator>rmuraly</dc:creator>
      <dc:date>2020-09-29T14:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354748#M104984</link>
      <description>&lt;P&gt;I had to extract the date from my source file and this helps me do it.&lt;/P&gt;

&lt;P&gt;| stats count | eval source="ABC_GFD_NOCS_RPT_HIST_2017-05-12_5min.csv"| rex field=source"(?\d{4}-\d{2}-\d{2})"&lt;BR /&gt;
| table Date,source&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:30:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354748#M104984</guid>
      <dc:creator>rmuraly</dc:creator>
      <dc:date>2020-09-29T14:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a date from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354749#M104985</link>
      <description>&lt;P&gt;@rmuraly, I have converted my comment as answer. Please accept to mark the question as answered.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 19:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-date-from-a-string/m-p/354749#M104985</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-06-15T19:43:11Z</dc:date>
    </item>
  </channel>
</rss>

