+ Reply to Thread
Results 1 to 6 of 6

Formula for getting data from week number (reverse WEEKNUM)

  1. #1
    Registered User
    Join Date
    02-01-2005
    Posts
    62

    Formula for getting data from week number (reverse WEEKNUM)

    Looking for a formula that works basically like the WEEKNUM function in reverse in ISO format. So, if given 3/2007 (week 3, year 2007) it will return Jan 15, 2007 (Monday, first day in week 3 of 2007).

    Not sure where to start. Any help would be appreciated.
    Last edited by grime; 02-01-2007 at 05:02 PM.

  2. #2
    Registered User
    Join Date
    02-01-2005
    Posts
    62
    Found my own answer... posting here for reference.

    Extracts the date of the monday in a given weeknumber (ISO). Cell E1 contains the year and E2 the weeknumber.

    =DATE($E$1,1,1)+($E$2-IF(WEEKDAY(DATE($E$1,1,1),2)<5,1,0))*7-WEEKDAY(DATE($E$1,1,1),2)+1

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    hello grime,

    this formula is a little shorter.....

    =DATE(E1,1,E2*7-2)-WEEKDAY(DATE(E1,1,3))

  4. #4
    Registered User
    Join Date
    04-28-2011
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    3

    Re: Formula for getting data from week number (reverse WEEKNUM)

    The two formulas proposed above seem to provide exactly the same results (at least from 2017 to 2053).
    However, these Excel ISO date manipulations have some particularities to watch for.

    For testing, I filled Col A of a worksheet with the real dates from 2017-01-01 (Sunday of ISO week 1, 2016) to 2053-12-29 (Monday of ISO week 1, 2054).

    Then,
    col B: =ISOWEEKNUM(columnA)
    col C: =TEXT(columnA,"yyyy")
    Col D: =TEXT(columnA,"d")
    Col E: =TEXT(columnA,"ddd")
    Col F: =DATE(columnC,1,1)+(columnB - IF(WEEKDAY(DATE(columnC,1,1),2)<5,1,0))*7 - WEEKDAY(DATE(columnC,1,1),2)+1
    Col G: =DATE(columnC,1,columnB*7-2) - WEEKDAY(DATE(columnC,1,3))
    The issue is : the year column, calculated using the text function, is NOT ALWAYS equal to the "ISO week-numbering year" (i.e. the "year" portion of an ISO week reference).
    In other words,
    2018-12-31 is year 2018 but ISO week #1 (2019)
    2019-12-30 is year 2019 but ISO week #1 (2020)
    2024-12-30 is year 2024 but ISO week #1 (2025)
    etc.
    See below:
    Clipboard01.png

    I could not find a ISOYEARNUM function in Excel, which would give the quasi-year number linked with the ISOYEARNUM.
    Seems at this point the only way is to use the formula below, from this post :
    =YEAR(ColumnA-WEEKDAY(ColumnA,3)+3)

    which is based on the particular properties of Thursdays under ISO-8601.
    Last edited by mach128x; 12-05-2017 at 07:22 PM. Reason: found the post with the formula for the ISO week-numbering year

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Formula for getting data from week number (reverse WEEKNUM)

    Hello mach128x,

    Yes, I agree with what you say. Obviously the "ISO week number year" and the real year never align correctly, any date in the range 29th December to 3rd Jan can be in the "wrong" year. A far as I know there's no better way to get the correct year than that formula you found, have you answered your own question?
    Audere est facere

  6. #6
    Registered User
    Join Date
    04-28-2011
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    3
    Quote Originally Posted by daddylonglegs View Post
    Hello mach128x,

    Yes, I agree with what you say. Obviously the "ISO week number year" and the real year never align correctly, any date in the range 29th December to 3rd Jan can be in the "wrong" year. A far as I know there's no better way to get the correct year than that formula you found, have you answered your own question?
    Yes I did.
    Lets hope MS provides a function for the ISO year in the future, though.
    Also thanks to you both for providing the formulas.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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