2019 incorrect week calculation by the standard date format mask












1















Normally I calculate the week of the year by the standard date format mask %Y%W. Till 2019 it worked quite good but last days I've noticed that the first week of the year 2019 (2018/12/31-2019/01/06) is shown like the last week number 53 from 2018. And only the week 2019/01/07-2019/01/13 is the first week of 2019. I've checked if it's correct.



Everywhere you can see that the week 2018/12/31-2019/01/06 is currently the first week of 2019. And even Oracle knows it to_char(..., 'yyyyiw'), but R doesn't. At least it should have the same opinion.



It does matter for me and I think it looks like a bug.
I'm using R 3.5.0.










share|improve this question





























    1















    Normally I calculate the week of the year by the standard date format mask %Y%W. Till 2019 it worked quite good but last days I've noticed that the first week of the year 2019 (2018/12/31-2019/01/06) is shown like the last week number 53 from 2018. And only the week 2019/01/07-2019/01/13 is the first week of 2019. I've checked if it's correct.



    Everywhere you can see that the week 2018/12/31-2019/01/06 is currently the first week of 2019. And even Oracle knows it to_char(..., 'yyyyiw'), but R doesn't. At least it should have the same opinion.



    It does matter for me and I think it looks like a bug.
    I'm using R 3.5.0.










    share|improve this question



























      1












      1








      1








      Normally I calculate the week of the year by the standard date format mask %Y%W. Till 2019 it worked quite good but last days I've noticed that the first week of the year 2019 (2018/12/31-2019/01/06) is shown like the last week number 53 from 2018. And only the week 2019/01/07-2019/01/13 is the first week of 2019. I've checked if it's correct.



      Everywhere you can see that the week 2018/12/31-2019/01/06 is currently the first week of 2019. And even Oracle knows it to_char(..., 'yyyyiw'), but R doesn't. At least it should have the same opinion.



      It does matter for me and I think it looks like a bug.
      I'm using R 3.5.0.










      share|improve this question
















      Normally I calculate the week of the year by the standard date format mask %Y%W. Till 2019 it worked quite good but last days I've noticed that the first week of the year 2019 (2018/12/31-2019/01/06) is shown like the last week number 53 from 2018. And only the week 2019/01/07-2019/01/13 is the first week of 2019. I've checked if it's correct.



      Everywhere you can see that the week 2018/12/31-2019/01/06 is currently the first week of 2019. And even Oracle knows it to_char(..., 'yyyyiw'), but R doesn't. At least it should have the same opinion.



      It does matter for me and I think it looks like a bug.
      I'm using R 3.5.0.







      r bugzilla






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 9 at 11:41









      Ahmed Ashour

      1,3401715




      1,3401715










      asked Jan 9 at 10:32









      Wladislaw PoniatowskiWladislaw Poniatowski

      62




      62






















          1 Answer
          1






          active

          oldest

          votes


















          1














          See ?strftime:




           ‘%U’ Week of the year as decimal number (00-53) using Sunday as
          the first day 1 of the week (and typically with the first
          Sunday of the year as day 1 of week 1). The US convention.

          ‘%V’ Week of the year as decimal number (01-53) as defined in ISO
          8601. If the week (starting on Monday) containing 1 January
          has four or more days in the new year, then it is considered
          week 1. Otherwise, it is the last week of the previous year,
          and the next week is week 1. (Accepted but ignored on
          input.)

          ‘%W’ Week of the year as decimal number (00-53) using Monday as
          the first day of week (and typically with the first Monday of
          the year as day 1 of week 1). The UK convention.



          The format mask IW in Oracle returns the ISO week number of the year, i.e. %V in R:



          R> x <- as.Date("2018-12-28") + 0:10
          R> data.frame(date=x, weeknum=format(x, "%V"))
          date weeknum
          1 2018-12-28 52
          2 2018-12-29 52
          3 2018-12-30 52
          4 2018-12-31 01
          5 2019-01-01 01
          6 2019-01-02 01
          7 2019-01-03 01
          8 2019-01-04 01
          9 2019-01-05 01
          10 2019-01-06 01
          11 2019-01-07 02





          share|improve this answer
























          • Thanks a lot! I didn't know about the mask with %V. It's not always present in the date format descriptions, you can find on the internet. I didn't know there's something else. It was also confusing that the %W mask has worked very well in 2018. Anyway thanks!

            – Wladislaw Poniatowski
            Jan 9 at 13:39













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1392225%2f2019-incorrect-week-calculation-by-the-standard-date-format-mask%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          See ?strftime:




           ‘%U’ Week of the year as decimal number (00-53) using Sunday as
          the first day 1 of the week (and typically with the first
          Sunday of the year as day 1 of week 1). The US convention.

          ‘%V’ Week of the year as decimal number (01-53) as defined in ISO
          8601. If the week (starting on Monday) containing 1 January
          has four or more days in the new year, then it is considered
          week 1. Otherwise, it is the last week of the previous year,
          and the next week is week 1. (Accepted but ignored on
          input.)

          ‘%W’ Week of the year as decimal number (00-53) using Monday as
          the first day of week (and typically with the first Monday of
          the year as day 1 of week 1). The UK convention.



          The format mask IW in Oracle returns the ISO week number of the year, i.e. %V in R:



          R> x <- as.Date("2018-12-28") + 0:10
          R> data.frame(date=x, weeknum=format(x, "%V"))
          date weeknum
          1 2018-12-28 52
          2 2018-12-29 52
          3 2018-12-30 52
          4 2018-12-31 01
          5 2019-01-01 01
          6 2019-01-02 01
          7 2019-01-03 01
          8 2019-01-04 01
          9 2019-01-05 01
          10 2019-01-06 01
          11 2019-01-07 02





          share|improve this answer
























          • Thanks a lot! I didn't know about the mask with %V. It's not always present in the date format descriptions, you can find on the internet. I didn't know there's something else. It was also confusing that the %W mask has worked very well in 2018. Anyway thanks!

            – Wladislaw Poniatowski
            Jan 9 at 13:39


















          1














          See ?strftime:




           ‘%U’ Week of the year as decimal number (00-53) using Sunday as
          the first day 1 of the week (and typically with the first
          Sunday of the year as day 1 of week 1). The US convention.

          ‘%V’ Week of the year as decimal number (01-53) as defined in ISO
          8601. If the week (starting on Monday) containing 1 January
          has four or more days in the new year, then it is considered
          week 1. Otherwise, it is the last week of the previous year,
          and the next week is week 1. (Accepted but ignored on
          input.)

          ‘%W’ Week of the year as decimal number (00-53) using Monday as
          the first day of week (and typically with the first Monday of
          the year as day 1 of week 1). The UK convention.



          The format mask IW in Oracle returns the ISO week number of the year, i.e. %V in R:



          R> x <- as.Date("2018-12-28") + 0:10
          R> data.frame(date=x, weeknum=format(x, "%V"))
          date weeknum
          1 2018-12-28 52
          2 2018-12-29 52
          3 2018-12-30 52
          4 2018-12-31 01
          5 2019-01-01 01
          6 2019-01-02 01
          7 2019-01-03 01
          8 2019-01-04 01
          9 2019-01-05 01
          10 2019-01-06 01
          11 2019-01-07 02





          share|improve this answer
























          • Thanks a lot! I didn't know about the mask with %V. It's not always present in the date format descriptions, you can find on the internet. I didn't know there's something else. It was also confusing that the %W mask has worked very well in 2018. Anyway thanks!

            – Wladislaw Poniatowski
            Jan 9 at 13:39
















          1












          1








          1







          See ?strftime:




           ‘%U’ Week of the year as decimal number (00-53) using Sunday as
          the first day 1 of the week (and typically with the first
          Sunday of the year as day 1 of week 1). The US convention.

          ‘%V’ Week of the year as decimal number (01-53) as defined in ISO
          8601. If the week (starting on Monday) containing 1 January
          has four or more days in the new year, then it is considered
          week 1. Otherwise, it is the last week of the previous year,
          and the next week is week 1. (Accepted but ignored on
          input.)

          ‘%W’ Week of the year as decimal number (00-53) using Monday as
          the first day of week (and typically with the first Monday of
          the year as day 1 of week 1). The UK convention.



          The format mask IW in Oracle returns the ISO week number of the year, i.e. %V in R:



          R> x <- as.Date("2018-12-28") + 0:10
          R> data.frame(date=x, weeknum=format(x, "%V"))
          date weeknum
          1 2018-12-28 52
          2 2018-12-29 52
          3 2018-12-30 52
          4 2018-12-31 01
          5 2019-01-01 01
          6 2019-01-02 01
          7 2019-01-03 01
          8 2019-01-04 01
          9 2019-01-05 01
          10 2019-01-06 01
          11 2019-01-07 02





          share|improve this answer













          See ?strftime:




           ‘%U’ Week of the year as decimal number (00-53) using Sunday as
          the first day 1 of the week (and typically with the first
          Sunday of the year as day 1 of week 1). The US convention.

          ‘%V’ Week of the year as decimal number (01-53) as defined in ISO
          8601. If the week (starting on Monday) containing 1 January
          has four or more days in the new year, then it is considered
          week 1. Otherwise, it is the last week of the previous year,
          and the next week is week 1. (Accepted but ignored on
          input.)

          ‘%W’ Week of the year as decimal number (00-53) using Monday as
          the first day of week (and typically with the first Monday of
          the year as day 1 of week 1). The UK convention.



          The format mask IW in Oracle returns the ISO week number of the year, i.e. %V in R:



          R> x <- as.Date("2018-12-28") + 0:10
          R> data.frame(date=x, weeknum=format(x, "%V"))
          date weeknum
          1 2018-12-28 52
          2 2018-12-29 52
          3 2018-12-30 52
          4 2018-12-31 01
          5 2019-01-01 01
          6 2019-01-02 01
          7 2019-01-03 01
          8 2019-01-04 01
          9 2019-01-05 01
          10 2019-01-06 01
          11 2019-01-07 02






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 9 at 12:12









          rcsrcs

          136116




          136116













          • Thanks a lot! I didn't know about the mask with %V. It's not always present in the date format descriptions, you can find on the internet. I didn't know there's something else. It was also confusing that the %W mask has worked very well in 2018. Anyway thanks!

            – Wladislaw Poniatowski
            Jan 9 at 13:39





















          • Thanks a lot! I didn't know about the mask with %V. It's not always present in the date format descriptions, you can find on the internet. I didn't know there's something else. It was also confusing that the %W mask has worked very well in 2018. Anyway thanks!

            – Wladislaw Poniatowski
            Jan 9 at 13:39



















          Thanks a lot! I didn't know about the mask with %V. It's not always present in the date format descriptions, you can find on the internet. I didn't know there's something else. It was also confusing that the %W mask has worked very well in 2018. Anyway thanks!

          – Wladislaw Poniatowski
          Jan 9 at 13:39







          Thanks a lot! I didn't know about the mask with %V. It's not always present in the date format descriptions, you can find on the internet. I didn't know there's something else. It was also confusing that the %W mask has worked very well in 2018. Anyway thanks!

          – Wladislaw Poniatowski
          Jan 9 at 13:39




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1392225%2f2019-incorrect-week-calculation-by-the-standard-date-format-mask%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy