<?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: Datetime to Date in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334461#M159835</link>
    <description>&lt;P&gt;If you have time please answer my new question:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/558724/last-7-days-based-on-field.html?minQuestionBodyLength=80"&gt;https://answers.splunk.com/answers/558724/last-7-days-based-on-field.html?minQuestionBodyLength=80&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jul 2017 03:44:03 GMT</pubDate>
    <dc:creator>luislema</dc:creator>
    <dc:date>2017-07-28T03:44:03Z</dc:date>
    <item>
      <title>Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334448#M159822</link>
      <description>&lt;P&gt;I have a field called Date like this 2017-07-26 22:34:09.383 and I need to strip out the time and keep just the date (2017-07-26). After that I need to group by Date. How do I do that? I have tried this but it's not working:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=mysource
| eval newtime=strftime(Date, "%Y-%m-%d")
| chart sum(Revenue) by newtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 22:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334448#M159822</guid>
      <dc:creator>luislema</dc:creator>
      <dc:date>2017-07-26T22:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334449#M159823</link>
      <description>&lt;P&gt;try this &lt;/P&gt;

&lt;P&gt;your search | rex field=_raw "(?P&amp;lt;extractedDate&amp;gt;\d+\-\d+\-\d+)\s+\d+:\d+:\d+.\d+"&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 02:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334449#M159823</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-27T02:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334450#M159824</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;If you just need a new time field with dates, you can try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search | eval newtime=strftime(_time, "%Y-%m-%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will create a new field called "newtime" that's a time field with only the date (year (Y), month (m), day of month (d)).&lt;/P&gt;

&lt;P&gt;See more information on the time functions here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/DateandTimeFunctions"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/DateandTimeFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And see more information on date and time format variables (the %Y, %m, etc.) here:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Commontimeformatvariables"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 11:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334450#M159824</guid>
      <dc:creator>hettervik</dc:creator>
      <dc:date>2017-07-27T11:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334451#M159825</link>
      <description>&lt;P&gt;If I'm not mistaken this would create a new field (extractedDate) that's a string, not a time field, meaning that one cannot do time operations with it unless converting it with "strptime" first.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 11:32:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334451#M159825</guid>
      <dc:creator>hettervik</dc:creator>
      <dc:date>2017-07-27T11:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334452#M159826</link>
      <description>&lt;P&gt;@hettervi&lt;/P&gt;

&lt;P&gt;As per my understanding luislema have timestamp in the events itself and wanted to extract only date portion from timestamp.  So in my search query i m not converting anything, so there is no chance to convert from epoch time to date stamp.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 13:41:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334452#M159826</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-27T13:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334453#M159827</link>
      <description>&lt;P&gt;Hi, I am trying to group by the newtime, and it's not working:&lt;/P&gt;

&lt;P&gt;my search| eval newtime=strftime(Date, "%Y-%m-%d")&lt;BR /&gt;
| chart sum(Revenue) by newtime&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 15:47:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334453#M159827</guid>
      <dc:creator>luislema</dc:creator>
      <dc:date>2017-07-27T15:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334454#M159828</link>
      <description>&lt;P&gt;try _time instead of DATE. if DATE field is not existed. &lt;/P&gt;

&lt;P&gt;below is the sample query&lt;/P&gt;

&lt;P&gt;index=_internal  group=per_source_thruput  |  eval newtime=strftime(_time, "%Y-%m-%d") | chart sum(kb) by newtime&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:05:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334454#M159828</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2020-09-29T15:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334455#M159829</link>
      <description>&lt;P&gt;Date is my field so I need to use it.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 17:14:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334455#M159829</guid>
      <dc:creator>luislema</dc:creator>
      <dc:date>2017-07-27T17:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334456#M159830</link>
      <description>&lt;P&gt;please check Revenue and Date field is exist. Query is fine.&lt;/P&gt;

&lt;P&gt;To confirm, please execute the query below, It should output some values. If not fields are not extracted properly. &lt;/P&gt;

&lt;P&gt;index=xx sourcetype=xxxx | table Date Revenue. &lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 18:12:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334456#M159830</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-27T18:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334457#M159831</link>
      <description>&lt;P&gt;Yes, when I run this it outputs the Date and Revenue.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 18:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334457#M159831</guid>
      <dc:creator>luislema</dc:creator>
      <dc:date>2017-07-27T18:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334458#M159832</link>
      <description>&lt;P&gt;Ah okay. can you paste your search query and one sample event.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 18:16:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334458#M159832</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-27T18:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334459#M159833</link>
      <description>&lt;P&gt;my search | table Date Revenue&lt;/P&gt;

&lt;P&gt;Date                                   Revenue&lt;BR /&gt;
2017-07-27 18:14:37.65  19.0000&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 18:19:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334459#M159833</guid>
      <dc:creator>luislema</dc:creator>
      <dc:date>2017-07-27T18:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334460#M159834</link>
      <description>&lt;P&gt;your search | rex field=Date "(?P&amp;lt;newField&amp;gt;\d+-\d+-\d+)\s\d+:\d+:\d+" | chart sum(Revenue) by newField&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 18:28:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334460#M159834</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-27T18:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334461#M159835</link>
      <description>&lt;P&gt;If you have time please answer my new question:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/558724/last-7-days-based-on-field.html?minQuestionBodyLength=80"&gt;https://answers.splunk.com/answers/558724/last-7-days-based-on-field.html?minQuestionBodyLength=80&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 03:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334461#M159835</guid>
      <dc:creator>luislema</dc:creator>
      <dc:date>2017-07-28T03:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime to Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334462#M159836</link>
      <description>&lt;P&gt;Never mind. I figured it out:&lt;BR /&gt;
my search&lt;BR /&gt;
| rex field=Date "(?P\d+-\d+-\d+)\s\d+:\d+:\d+" &lt;BR /&gt;
| eval n=relative_time(now(), "-7d@d") &lt;BR /&gt;
| eval newtime=strptime(Date, "%Y-%m-%d")&lt;BR /&gt;
| where newtime &amp;gt;= n &lt;BR /&gt;
| chart sum(Revenue) AS Revenue by Day&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 04:12:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Datetime-to-Date/m-p/334462#M159836</guid>
      <dc:creator>luislema</dc:creator>
      <dc:date>2017-07-28T04:12:57Z</dc:date>
    </item>
  </channel>
</rss>

