<?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: How to define time period in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614675#M213623</link>
    <description>&lt;P&gt;Still unclear what "&lt;SPAN&gt;a value for 8 hours period" is supposed to mean. &amp;nbsp;In number of seconds? &amp;nbsp;An time (epoch) value starting from that "date" with offset of 8 hours? Some sort of string (as you have already defined)? &amp;nbsp;There can be millions of interpretations of this phrase.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Sep 2022 06:08:09 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-09-27T06:08:09Z</dc:date>
    <item>
      <title>How to define time period?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614670#M213619</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;For example, the "SUBMIT_DATE" is split by date and time. Then define some period of time as a value(A/B/C). Can this be achieved?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;(SUBMIT_DATE=&lt;/SPAN&gt;"&lt;SPAN class=""&gt;2021-03-09&lt;/SPAN&gt; &lt;SPAN class=""&gt;14:30:48.0&lt;/SPAN&gt;")&amp;nbsp; ==&amp;gt; Split to "&lt;SPAN class=""&gt;2021-03-09"&lt;/SPAN&gt; &lt;SPAN class=""&gt;and "14:30:48.0"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;0:00:00 - 8:00:00 = A&lt;/P&gt;
&lt;P&gt;8:00:00 - 16:00:00 = B&lt;/P&gt;
&lt;P&gt;16:00:00 - 0:00:00 = C&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Sep 2022 13:33:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614670#M213619</guid>
      <dc:creator>simon1524</dc:creator>
      <dc:date>2022-09-27T13:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614672#M213621</link>
      <description>&lt;P&gt;Can you explain what "&lt;SPAN&gt;Then define some period of time as a value(A/B/C)" means? &amp;nbsp;You have already defined A, B, and C in your description. &amp;nbsp;What is missing?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To split SUBMIT_DATE is simple,&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval SUBMIT_DATE = split(SUBMIT_DATE, " ")
| eval part1 = mvindex(SUBMIT_DATE, 0), part2 = mvindex(SUBMIT_DATE, 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 05:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614672#M213621</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-09-27T05:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614673#M213622</link>
      <description>&lt;P&gt;I want to split （SUBMIT_DATE） into “date” and “time”.&lt;BR /&gt;Then define a value for 8 hours period, such as below.&lt;BR /&gt;0:00:00 - 8:00:00 = A&lt;/P&gt;&lt;P&gt;8:00:00 - 16:00:00 = B&lt;/P&gt;&lt;P&gt;16:00:00 - 0:00:00 = C&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 06:02:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614673#M213622</guid>
      <dc:creator>simon1524</dc:creator>
      <dc:date>2022-09-27T06:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614675#M213623</link>
      <description>&lt;P&gt;Still unclear what "&lt;SPAN&gt;a value for 8 hours period" is supposed to mean. &amp;nbsp;In number of seconds? &amp;nbsp;An time (epoch) value starting from that "date" with offset of 8 hours? Some sort of string (as you have already defined)? &amp;nbsp;There can be millions of interpretations of this phrase.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 06:08:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614675#M213623</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-09-27T06:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614676#M213624</link>
      <description>&lt;P&gt;According to the data on the system, it should be accurate to the second.&lt;/P&gt;&lt;P&gt;| eval SUBMIT_DATE = split(SUBMIT_DATE, " ")&lt;BR /&gt;| eval part1 = mvindex(SUBMIT_DATE, 0), part2 = mvindex(SUBMIT_DATE, 1)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;According to the function you give&lt;/P&gt;&lt;P&gt;"00:00:00 &amp;gt; part2 &amp;gt;= 08:00:00" as A&lt;/P&gt;&lt;P&gt;"08:00:00 &amp;gt; part2 &amp;gt;= 16:00:00" as B&lt;/P&gt;&lt;P&gt;"16:00:00 &amp;gt; part2 &amp;gt;= 00:00:00" as C&lt;/P&gt;&lt;P&gt;I wonder how to define it...&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 06:28:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614676#M213624</guid>
      <dc:creator>simon1524</dc:creator>
      <dc:date>2022-09-27T06:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614679#M213626</link>
      <description>&lt;P&gt;If I understand this correctly, you want to define a function that outputs "A", "B", or "C" according to which 8-hour interval the time of day in SUBMIT_DATE falls into. &amp;nbsp;In other words, you are looking for a&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions#case.28X.2C.22Y.22.2C....29" target="_blank" rel="noopener"&gt;case&lt;/A&gt;&amp;nbsp;function.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval SUBMIT_DATE = split(SUBMIT_DATE, " ")
| eval date = mvindex(SUBMITE_DATE, 0), time_of_day = strptime(mvindex(SUBMIT_DATE, 1), "%H:%M:%S")
| eval shift = case(time_of_day &amp;lt; 28800, "A", 28800 &amp;lt;= time_of_day AND time_of_day &amp;lt; 57600, "B", true(), "C")&lt;/LI-CODE&gt;&lt;P&gt;Does this help? Note that time_of_day is in number of seconds from 00:00:00 whereas date is still in string format. &amp;nbsp;If you want to convert that to epoch, use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions#strptime.28X.2CY.29" target="_blank" rel="noopener"&gt;strptime&lt;/A&gt; again.&lt;/P&gt;&lt;P&gt;Also note that is perhaps not the most elegant to split SUBMIT_DATE into substrings before converting to numeric. &amp;nbsp;But the formula should work.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 07:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614679#M213626</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-09-27T07:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614846#M213677</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Got the first step done by your query.&lt;/P&gt;&lt;P&gt;| eval SUBMITED_DATE = split(SUBMITED_DATE, " ")&lt;BR /&gt;| eval date = mvindex(SUBMITED_DATE, 0), time_of_day = strptime(mvindex(SUBMITED_DATE, 1), "%H:%M:%S")&lt;BR /&gt;| eval shift = case(time_of_day &amp;lt; 1664258400, "A", 1664258400 &amp;lt;= time_of_day AND time_of_day &amp;lt; 1664287200, "B", true(), "C")&lt;/P&gt;&lt;P&gt;The next step is to count the number of each month&lt;/P&gt;&lt;P&gt;| timechart span = 1mon count(eval(shift = "A")) as first_shift, count(eval(shift = "B")) as second_shift, count(eval(shift = "C")) as third_shift&lt;BR /&gt;| tail 12&lt;BR /&gt;| sort _time&lt;/P&gt;&lt;P&gt;As you see my query, I want to count every shift in every month of the last year. But there is something wrong with above query...&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 28 Sep 2022 01:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614846#M213677</guid>
      <dc:creator>simon1524</dc:creator>
      <dc:date>2022-09-28T01:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614863#M213679</link>
      <description>&lt;P&gt;Without an illustration, it is unclear what "&lt;SPAN&gt;count every shift in every month" really means. &amp;nbsp;If you want to know how many events per month are in each shift, i.e., count by shift, you can use&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart span=1mon count by shift
| tail 12&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Is this what you require?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 05:51:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614863#M213679</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-09-28T05:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to define time period</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614864#M213680</link>
      <description>&lt;P&gt;Thank you very much! The result is showing now~&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 28 Sep 2022 05:59:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-time-period/m-p/614864#M213680</guid>
      <dc:creator>simon1524</dc:creator>
      <dc:date>2022-09-28T05:59:52Z</dc:date>
    </item>
  </channel>
</rss>

