<?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: String to Date Conversion in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107656#M27988</link>
    <description>&lt;P&gt;So you are having trouble extracting the date in the first place?&lt;/P&gt;

&lt;P&gt;If your rex is/was working, then your error is pertaining to the fact that you are trying to perform the convert on the field called "Date", but you are extracting to a field called "date". When dealing with fields, case matters.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Oct 2013 14:17:43 GMT</pubDate>
    <dc:creator>aholzer</dc:creator>
    <dc:date>2013-10-21T14:17:43Z</dc:date>
    <item>
      <title>String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107653#M27985</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;I am new to splunk and currently we are working to visualize splunk reports to Tableau, but when we import data into Tableau using Splunk ODBC driver we get Date field as string in splunk.In Tableau for increamental Refersh required either int or Date field and hence it is not working.&lt;/P&gt;

&lt;P&gt;My query is as follows.&lt;/P&gt;

&lt;P&gt;index="indexname" sourcetype="Sourcetype" Search condition | stats count by Date&lt;/P&gt;

&lt;P&gt;Please help me out.&lt;/P&gt;

&lt;P&gt;Thanks is advance.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Sandeep Thosar&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2013 13:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107653#M27985</guid>
      <dc:creator>sandeep_thosar</dc:creator>
      <dc:date>2013-10-21T13:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107654#M27986</link>
      <description>&lt;P&gt;Look at the convert command:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Convert" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Convert&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Example: index="indexname" sourcetype="Sourcetype" Search condition | convert auto(Date) | stats count by Date&lt;/P&gt;

&lt;P&gt;Or look at the strptime() function:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/CommonEvalFunctions" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Commontimeformatvariables" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Example: index="indexname" sourcetype="Sourcetype" Search condition | eval date_time = strptime(Date, "%H:%M") | stats count by date_time&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:01:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107654#M27986</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2020-09-28T15:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107655#M27987</link>
      <description>&lt;P&gt;Thanks for help Aholzerbut still i am facing issue with rex as i am extracing date field using rex, so can you told me how to aply eval function with rex beacuse i am trying the same and get error invalid rex command.please find query with Rexindex="indexname" sourcetype="Sourcetype" Search condition | rex "[(?P&lt;DATE&gt;[^ :s*?]+)" | convert auto(Date) | stats count by DatePlease help me.Thanks in advance.&lt;/DATE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2013 14:11:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107655#M27987</guid>
      <dc:creator>sandeep_thosar</dc:creator>
      <dc:date>2013-10-21T14:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107656#M27988</link>
      <description>&lt;P&gt;So you are having trouble extracting the date in the first place?&lt;/P&gt;

&lt;P&gt;If your rex is/was working, then your error is pertaining to the fact that you are trying to perform the convert on the field called "Date", but you are extracting to a field called "date". When dealing with fields, case matters.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2013 14:17:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107656#M27988</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2013-10-21T14:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107657#M27989</link>
      <description>&lt;P&gt;Hi Aholzer,&lt;/P&gt;

&lt;P&gt;sorry it's typo mistake, but still it's not working.&lt;/P&gt;

&lt;P&gt;Please suggest me my folloiwng query is right or i want to change something to work your suggetion.&lt;/P&gt;

&lt;P&gt;Rexindex="indexname" sourcetype="Sourcetype" Search condition | rex "[(?P&lt;DATE&gt;[^ :s*?]+)" | eval date_time = strptime(Date, "%H:%M")| stats count by DatePlease &lt;/DATE&gt;&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Sandeep&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2013 14:34:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107657#M27989</guid>
      <dc:creator>sandeep_thosar</dc:creator>
      <dc:date>2013-10-21T14:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107658#M27990</link>
      <description>&lt;P&gt;The strptime(Date, "%H:%M") was just an example, I don't know what the pattern of your time is... You are going to have to change the "%H:%M" to match your time pattern. Look at the third link I sent you for pattern options.&lt;/P&gt;

&lt;P&gt;Before you get into testing the strptime, you should probably confirm that your rex is working.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2013 14:36:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107658#M27990</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2013-10-21T14:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107659#M27991</link>
      <description>&lt;P&gt;As aholzer says, make sure your rex is properly extracting your date.  Then give us an example of what the extracted date looks like.  Then we can possibly give you a suggestion for how to convert it.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2013 21:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107659#M27991</guid>
      <dc:creator>emiller42</dc:creator>
      <dc:date>2013-10-21T21:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107660#M27992</link>
      <description>&lt;P&gt;I assume you are getting date in epoch time...&lt;/P&gt;

&lt;P&gt;Try putting this in your search command at the end...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval Date=strftime(Date, "%m/%d/%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will make the epoch time stamp look like 10/21/2013 21:19:00&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2013 02:19:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107660#M27992</guid>
      <dc:creator>ShaneNewman</dc:creator>
      <dc:date>2013-10-22T02:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107661#M27993</link>
      <description>&lt;P&gt;Your query would be a lot easier to answer if we could see a sample of the data you are attempting to reformat, rather than flying blind and guessing.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2013 03:15:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107661#M27993</guid>
      <dc:creator>grijhwani</dc:creator>
      <dc:date>2013-10-22T03:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107662#M27994</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for the reply.&lt;/P&gt;

&lt;P&gt;Please find below sample data for your reference.&lt;/P&gt;

&lt;P&gt;Event1 server1 [17/Oct/2013:00:00:52 -0500] "IPAddress&lt;BR /&gt;
Event2 server1 [17/Oct/2013:01:02:59 -0500] "IPAddress&lt;BR /&gt;
Event3 server1 [18/Oct/2013:02:00:50 -0500] "IPAddress&lt;/P&gt;

&lt;P&gt;Please find search query&lt;BR /&gt;
index=Indexname sourcetype="Sourcetype" "Search Condition" | rex "[(?P&lt;DATE&gt;[^ :\s*?]+)" | stats count As Total by Date&lt;/DATE&gt;&lt;/P&gt;

&lt;P&gt;Date            Total&lt;BR /&gt;
01-Oct-2013      2&lt;BR /&gt;
01-Oct-2013      1&lt;/P&gt;

&lt;P&gt;Above output date columns datetype is string and i reuqired this to convert into Date format ("dd-mm-yyy")&lt;/P&gt;

&lt;P&gt;Please help me.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Sandeep&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2013 06:48:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107662#M27994</guid>
      <dc:creator>sandeep_thosar</dc:creator>
      <dc:date>2013-10-23T06:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107663#M27995</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am tried above but still unable to convert string into date it's just change the date format.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2013 07:02:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107663#M27995</guid>
      <dc:creator>sandeep_thosar</dc:creator>
      <dc:date>2013-10-23T07:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107664#M27996</link>
      <description>&lt;P&gt;Using this link &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Commontimeformatvariables"&gt;http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Commontimeformatvariables&lt;/A&gt; you can use this pattern "%d-%b-%Y" to convert to a date.&lt;/P&gt;

&lt;P&gt;Here's the strptime function call that should work for you:&lt;BR /&gt;
strptime(Date, "%d-%b-%Y")&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2013 16:02:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107664#M27996</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2013-10-23T16:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107665#M27997</link>
      <description>&lt;P&gt;Actually, just a small modification to aholzer's comment: strptime(Date, "%d/%b/%Y")&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2013 03:13:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107665#M27997</guid>
      <dc:creator>ShaneNewman</dc:creator>
      <dc:date>2013-10-24T03:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107666#M27998</link>
      <description>&lt;P&gt;@ShaneNewman, if you notice after he does the extraction the Date field looks like "01-Oct-2013", hence why I used the dashes (-) rather than the slashes (/)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2013 14:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107666#M27998</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2013-10-28T14:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: String to Date Conversion</title>
      <link>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107667#M27999</link>
      <description>&lt;P&gt;That would be my bad...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2013 23:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/String-to-Date-Conversion/m-p/107667#M27999</guid>
      <dc:creator>ShaneNewman</dc:creator>
      <dc:date>2013-10-28T23:53:44Z</dc:date>
    </item>
  </channel>
</rss>

