+ Reply to Thread
Results 1 to 7 of 7

Week Number Problem with Calendar

  1. #1
    Forum Contributor
    Join Date
    04-23-2014
    Location
    United Kingdom
    MS-Off Ver
    Microsoft 365
    Posts
    149

    Week Number Problem with Calendar

    I've built a dynamic calendar in Excel that allows the user to set the start day and year they want to see. The only problem is the week numbers are not returning correctly.

    As someone from Europe, I am familiar with the ISO 8601 calendar standard, which means:

    • Week 1 begins on Monday.
    • Week 1 must have at least four days belonging to the new year.

    The ISOWEEKNUM function is ideal for this, however, it only works when the start day is Monday. WEEKNUM provides more options, but they are all based on the American system (except option 21), where the first week of the year is the one with January 1st in it and Sunday is the start day.

    I want to apply the ISO 4/7 majority rule to other days as well. I found an customisable online calendar that does this perfectly, and I've dumped three screenshots in the example workbook.

    Using Wednesday as the example, the week numbers that begin in G13 need to match the online calendar's. At the moment, I get strange results, e.g. 2022 starts at week 53 and then jumps to week 2.

    Please see the attachment.

    You'll see to the right of the calendar I've had a few attempts, but to no avail. I appreciate any help with this frustrating issue.
    Attached Files Attached Files
    Last edited by Statto; 02-05-2022 at 07:29 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,150

    Re: Week Number Problem with Calendar

    And you expect to see....

    53 followed by 1,2,3, etc... or what??
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Contributor
    Join Date
    04-23-2014
    Location
    United Kingdom
    MS-Off Ver
    Microsoft 365
    Posts
    149

    Re: Week Number Problem with Calendar

    In the example I've given, the year is 2022 and the start day is Wednesday. The week numbers in cell G13 need to match what's on the 2022 online calendar screenshot.

    Instead of:

    53
    2
    3
    4
    5
    6
    7
    etc.

    It should be:

    1
    2
    3
    4
    5
    6
    7
    etc.

    Be aware of the differences between years. For example, 2022 starts at week 1, whereas 2023 begins at 53 and 2024 at 52.

    The formula currently being used is:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This doesn't work correctly.
    Last edited by Statto; 02-05-2022 at 09:17 AM.

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Week Number Problem with Calendar

    Maybe try

    =WEEKNUM(INDEX(AK13#,,1)-MOD(MATCH(dd1.StartDay,TEXT(SEQUENCE(7,,3),"dddd"),),7)+7*(TEXT(DATE(sp1.Year,1,1),"dddd")=dd1.StartDay),21)
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    04-23-2014
    Location
    United Kingdom
    MS-Off Ver
    Microsoft 365
    Posts
    149

    Re: Week Number Problem with Calendar

    Thanks for trying, but unfortunately that doesn't work because it's displaying 52 for the first and last week of 2022, when it should range from 1–53 (as shown in the screenshot). The week numbers also aren't returning correctly for other years.

    Ideally, I'm also looking for a formula that doesn't change the existing formula responsible for the main part of the calendar. It seems to be a harder problem to solve than I was expecting.

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Week Number Problem with Calendar

    If you want the weeknum start from 1, Then end of the year wouldn't reach Weekno. 53
    But That is up to you.

    I can't do inconsistence formula to make end of the previous year end at week 53, when the current year end at week 52.
    I'm out.
    Attached Images Attached Images
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    04-23-2014
    Location
    United Kingdom
    MS-Off Ver
    Microsoft 365
    Posts
    149

    Re: Week Number Problem with Calendar

    Okay, but remember, we are starting from Wednesday — not Monday. In your example, you used WEEKNUM option 21, which assumes Monday is the start day.

    I don't think what I want to achieve can be done with WEEKNUM or ISOWEEKNUM. I suspect I need to rely on SEQUENCE to generate the set of numbers I'm after. But as you say, it is inconsistent, which makes it a challenge.

    I can return 1 when the opening week contains four or more days:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The challenge is when there are fewer than four days. The starting week could be 52 or 53, but the pattern varies.

    I've just cycled through the online calendar repeatedly to try and spot a pattern (using Wednesday as the start day). I've noticed:

    When there are three days in the first row belonging to the new year, the week number is usually 53. The exception is when 31st December of the previous year falls on Sunday. In this case, only two days in the first row belong to the new year, but the week number is 53. In any other case, it's 52.

    https://www.timeanddate.com/calendar...w=3&wno=4&df=1

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Calendar Automatic Day of Week Problem
    By gloriousglenn in forum Excel General
    Replies: 4
    Last Post: 11-24-2020, 09:23 AM
  2. [SOLVED] How to derive a week number from a Retail Week Calendar
    By moconn in forum Excel General
    Replies: 17
    Last Post: 03-01-2020, 02:10 PM
  3. [SOLVED] Lookup Date and find Week Number (Bespoke Calendar)
    By Gazsim in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-13-2019, 10:46 AM
  4. offset week number for a 4-4-5 calendar
    By jjjjjjjjunit in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-22-2017, 09:18 AM
  5. Replies: 6
    Last Post: 05-08-2013, 01:46 PM
  6. Calendar VBA auto filling week and month based on calendar entry.
    By perrymagic in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2011, 02:00 PM
  7. date --> calendar week number
    By jmwismer in forum Excel General
    Replies: 8
    Last Post: 10-03-2009, 10:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1