<?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: Is it possible to display\calculate the ISO year number for a date ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398079#M173685</link>
    <description>&lt;P&gt;You should submit a Support request to report that bug.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jan 2019 14:02:25 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2019-01-14T14:02:25Z</dc:date>
    <item>
      <title>Is it possible to display\calculate the ISO year number for a date ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398078#M173684</link>
      <description>&lt;P&gt;With strftime(_time, "%Y-%V"), I can create a period to sort on a year and ISO weeknumber.&lt;/P&gt;

&lt;P&gt;When I have events on 30-12-2018, 31-12-2018 and 01-01-2019 there is a sort problem.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;strftime(30-12-2018, "%Y-%V")  -&amp;gt; 2018-52
strftime(31-12-2018, "%Y-%V")  -&amp;gt; 2018-01 this should be 2019-01 for a correct sort
strftime(01-01-2019, "%Y-%V")  -&amp;gt; 2019-01
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is it possible to display or calculate the iso year number for a date ?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 12:54:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398078#M173684</guid>
      <dc:creator>dirkpeter</dc:creator>
      <dc:date>2019-01-14T12:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to display\calculate the ISO year number for a date ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398079#M173685</link>
      <description>&lt;P&gt;You should submit a Support request to report that bug.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 14:02:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398079#M173685</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-01-14T14:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to display\calculate the ISO year number for a date ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398080#M173686</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I do not think that is a bug because &lt;CODE&gt;%Y&lt;/CODE&gt; will always give you year from that date so it will always give you 2018 only.&lt;BR /&gt;
Well I have found a workaround for this :&lt;/P&gt;

&lt;P&gt;Try this run anywhere search :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval date="30-12-2018,31-12-2018,01-01-2019" 
| makemv date delim="," 
| mvexpand date 
| table date 
| eval date_epoch=strptime(date,"%d-%m-%Y") 
| eval year=strftime(date_epoch,"%Y"),day_mon=strftime(date_epoch,"%d-%m"),new_year=if(like(date,"31-12-%"),year+1,year) 
| eval new_date=day_mon+"-"+new_year 
| eval new_date=strptime(new_date,"%d-%m-%Y") 
| eval ISOWN=strftime(new_date,"%Y-%V") 
| table date ISOWN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically what I have done is whenever date is &lt;CODE&gt;31-12-* it will add +1 to the year so %Y will not fail.&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 14:43:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398080#M173686</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-01-14T14:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to display\calculate the ISO year number for a date ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398081#M173687</link>
      <description>&lt;P&gt;Hi @mayurr98&lt;/P&gt;

&lt;P&gt;As per the above logic for  30-12-2019 it should be Week 01, 2020. but its giving wrong as 2019-01.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 14:52:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398081#M173687</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-14T14:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to display\calculate the ISO year number for a date ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398082#M173688</link>
      <description>&lt;P&gt;I want to calculate the ISO year number based on a date.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;First ISO week:&lt;/STRONG&gt;&lt;BR /&gt;
The ISO 8601 definition for week 01 is the week with the Gregorian year's first Thursday in it. The following definitions based on properties of this week are mutually equivalent, since the ISO week starts with Monday: &lt;BR /&gt;
It is the first week with a majority (4 or more) of its days in January.&lt;BR /&gt;
Its first day is the Monday nearest to 1 January.&lt;BR /&gt;
It has 4 January in it. Hence the earliest possible first week extends from Monday 29 December (previous Gregorian year) to Sunday 4 January, the latest possible first week extends from Monday 4 January to Sunday 10 January.&lt;BR /&gt;
It has the year's first working day in it, if Saturdays, Sundays and 1 January are not working days.&lt;/P&gt;

&lt;P&gt;ISO YEAR    ISO WEEK    Starts on&lt;BR /&gt;
2019    1   ma 31-12-2018&lt;BR /&gt;
2020    1   ma 30-12-2019&lt;BR /&gt;
2021    1   ma 04-01-2021&lt;BR /&gt;
2022    1   ma 03-01-2022&lt;BR /&gt;
2023    1   ma 02-01-2023&lt;BR /&gt;
2024    1   ma 01-01-2024&lt;BR /&gt;
2025    1   ma 30-12-2024&lt;BR /&gt;
2026    1   ma 29-12-2025&lt;/P&gt;

&lt;P&gt;If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, it is part of week 53 of the previous year. If it is on a Saturday, it is part of the last week of the previous year which is numbered 52 in a common year and 53 in a leap year. If it is on a Sunday, it is part of week 52 of the previous year. &lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 15:04:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-display-calculate-the-ISO-year-number-for-a/m-p/398082#M173688</guid>
      <dc:creator>dirkpeter</dc:creator>
      <dc:date>2019-01-21T15:04:04Z</dc:date>
    </item>
  </channel>
</rss>

