<?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: given a date find which week of the year in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296060#M160331</link>
    <description>&lt;P&gt;Sorry but i missed one information earlier.&lt;BR /&gt;
I am working on .csv file which has column "date" on which we need to apply the above logic .&lt;BR /&gt;
eval WeekOfYear= strftime(date,"%V") - this doesn't work for me&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2017 13:07:52 GMT</pubDate>
    <dc:creator>ajaylowes</dc:creator>
    <dc:date>2017-07-05T13:07:52Z</dc:date>
    <item>
      <title>given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296051#M160322</link>
      <description>&lt;P&gt;given a date find which week of the year&lt;/P&gt;

&lt;P&gt;For example :  if date is "27-Feb-17" the result will be "09".&lt;BR /&gt;
As 27th Feb 2017 comes in 9th Week of that year.&lt;/P&gt;

&lt;P&gt;Another example: 8-Mar-17 will give "10" result.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 11:48:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296051#M160322</guid>
      <dc:creator>ajaylowes</dc:creator>
      <dc:date>2017-07-05T11:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296052#M160323</link>
      <description>&lt;P&gt;You'll probably have to write a custom command to do that.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:49:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296052#M160323</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-07-05T12:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296053#M160324</link>
      <description>&lt;P&gt;@ajaylowes, you can try &lt;CODE&gt;%U&lt;/CODE&gt; date time conversion for Week of the Year&lt;BR /&gt;
Following is run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval WeekOfYear=strftime(_time,"%U")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:51:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296053#M160324</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-05T12:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296054#M160325</link>
      <description>&lt;P&gt;not sure how to do it but you can quickly create an excel spreadsheet like explained below:&lt;BR /&gt;
&lt;A href="https://exceljet.net/formula/get-week-number-from-date"&gt;https://exceljet.net/formula/get-week-number-from-date&lt;/A&gt;&lt;BR /&gt;
save as csv -&amp;gt; upload as a lookup -&amp;gt; use as you wish&lt;BR /&gt;
hope it helps&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:52:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296054#M160325</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-07-05T12:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296055#M160326</link>
      <description>&lt;P&gt;for eval WeekOfYear=strftime(_time,"%U") , instead of _time can it take value from a column say "SubmitDate"&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:53:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296055#M160326</guid>
      <dc:creator>ajaylowes</dc:creator>
      <dc:date>2017-07-05T12:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296056#M160327</link>
      <description>&lt;P&gt;try adding this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval weeknum=strftime(_time,"%V")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I believe it runs Monday-Sunday, regardless of the day the year started.  I also don't believe it's supported by Splunk, as it's not listed here: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:54:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296056#M160327</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-07-05T12:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296057#M160328</link>
      <description>&lt;P&gt;@cmerriman, seemed like %U and %V were missing in Splunk Documentation. I have submitted a feedback for adding the same.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;%U&lt;/CODE&gt;-   Week number of the year [0-53], Sunday is the first day of the week. Used in calculating the day of the year.&lt;BR /&gt;
&lt;CODE&gt;%V&lt;/CODE&gt;-   ISO week number of the year [1-53]. Monday is the first day of the week. If the week containing January 1st has four or more days in the new year, it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1 of the new year. Used in calculating the day of the year.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:57:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296057#M160328</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-05T12:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296058#M160329</link>
      <description>&lt;P&gt;Yes, however, SubmitDate should be epoch time and not string time.&lt;/P&gt;

&lt;P&gt;Following is run anywhere search to convert to epoch time first prior to converting to Week Of Year&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval SubmitDate="27-Feb-17"
| eval SubmitDate=strptime(SubmitDate,"%d-%b-%y")
| eval WeekOfYear=strftime(SubmitDate,"%U")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 13:02:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296058#M160329</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-05T13:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296059#M160330</link>
      <description>&lt;P&gt;Sorry but i missed one information earlier.&lt;BR /&gt;
I am working on .csv file which  has  column "date" on which we need to apply the above logic .&lt;BR /&gt;
eval WeekOfYear= strftime(date,"%V")    - this doesn't work for me&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 13:07:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296059#M160330</guid>
      <dc:creator>ajaylowes</dc:creator>
      <dc:date>2017-07-05T13:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296060#M160331</link>
      <description>&lt;P&gt;Sorry but i missed one information earlier.&lt;BR /&gt;
I am working on .csv file which has column "date" on which we need to apply the above logic .&lt;BR /&gt;
eval WeekOfYear= strftime(date,"%V") - this doesn't work for me&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 13:07:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296060#M160331</guid>
      <dc:creator>ajaylowes</dc:creator>
      <dc:date>2017-07-05T13:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296061#M160332</link>
      <description>&lt;P&gt;you'll need to make that into epoch time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval date=strptime(date,"%d-%b-%y")
| eval yearNum=strftime(date,"%V")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 13:12:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296061#M160332</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-07-05T13:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296062#M160333</link>
      <description>&lt;P&gt;@ajaylowes, have you tried above example. strptime need to be run first on String Time.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 14:11:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296062#M160333</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-05T14:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296063#M160334</link>
      <description>&lt;P&gt;Does eval SubmitDate="17-Feb-17" accepts column name ( example: "date")  and then apply this to all the values of that column ?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 15:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296063#M160334</guid>
      <dc:creator>ajaylowes</dc:creator>
      <dc:date>2017-07-05T15:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296064#M160335</link>
      <description>&lt;P&gt;First two lines here are sample to generate mock data since you had not provided the name of the field earlier. 3rd and 4th lines perform the actual conversion that your need. Following is the query that you should apply to your base search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval date=strptime(date,"%d-%b-%y")
 | eval WeekOfYear=strftime(date,"%U")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I can see that @cmerriman has already suggested you this. Please try out and let us know if this does not work. If you face any issue please provide further details. Kindly upvote all comments that helped and accept any one of the solution once the issue is resolved.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 02:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296064#M160335</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-06T02:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: given a date find which week of the year</title>
      <link>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296065#M160336</link>
      <description>&lt;P&gt;Thanks @niketnilay ....its working now&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 09:01:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/given-a-date-find-which-week-of-the-year/m-p/296065#M160336</guid>
      <dc:creator>ajaylowes</dc:creator>
      <dc:date>2017-07-06T09:01:00Z</dc:date>
    </item>
  </channel>
</rss>

