Consulting

Results 1 to 12 of 12

Thread: Weeknum() function

  1. #1
    VBAX Regular Juha_Antero's Avatar
    Joined
    Jan 2005
    Location
    Finland
    Posts
    8
    Location

    Weeknum() function

    Hi everyone,
    seems I do not know how to use the WEEKNUM() function since it seems to give me wrong numbers. And yes, this regardless of the additional parameter 1 or 2 (which accounts for the first day of week). More specifically: today we are living the week number 2 but WEEKNUM() function in Excel returns 3. Can anybody explain why and is there anywhere any cure for the ailment?
    Of course there is the =WEEKNUM(now();2)-1 solution, but that is not what I am looking for...
    Regards
    Juha Antero

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Today (1-10-05) is the third week of the year. If weeks start on Sunday then the first week was just one day (Saturday 1-1-05). And if the weeks start on Monday then the first week was just two days (Saturday 1-1-05 to Sunday 1-2-05).

    If you want to count full 7 day weeks then try this.
      =INT((TODAY()-DATE(2005,1,1))/7)

  3. #3
    VBAX Regular Juha_Antero's Avatar
    Joined
    Jan 2005
    Location
    Finland
    Posts
    8
    Location

    Weeknum () again

    Hi Jacob,
    actually we do start our year with the week having at least 4 days in Jan. So unfortunately there seems to be no internationally recognised standard for this (to my great surprise, since the EU seem to issue directives on things even smaller, eg. the bend of a banana or a cucumber and such all important matters). It really is week 2 in Finland whereas in Excel the week is 3.
    Your esteemed solution results in 1 (1,45...)..

    Regs
    Juha

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    The formula was just for full 7 day weeks. So there has just been one week (and 3 days). If you want the current week you can try this.
      =ROUNDUP((TODAY()-DATE(2005,1,1))/7,0)

  5. #5
    VBAX Regular Juha_Antero's Avatar
    Joined
    Jan 2005
    Location
    Finland
    Posts
    8
    Location
    Thanks,
    this works OK as long as I change the date-part: DATE(YEAR(NOW());1;2) to start the week with a Monday..
    Regs
    JA

  6. #6
    VBAX Regular Juha_Antero's Avatar
    Joined
    Jan 2005
    Location
    Finland
    Posts
    8
    Location
    ..to continue: try with 31.12.2004 which was supposed to be week 53 the above gives 52, so need to be careful, or ...

  7. #7
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    How about this?
     =ROUNDUP((A1-DATE(YEAR(A1),1,1))/7,0)
    Where A1 houses the date to check.

  8. #8
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    You could check out this page, it gives some details on weeknumbers in Excel:

    http://www.cpearson.com/excel/weeknum.htm

  9. #9
    VBAX Regular Juha_Antero's Avatar
    Joined
    Jan 2005
    Location
    Finland
    Posts
    8
    Location
    Brilliant, all the things I need.
    Thanks a bunch.

  10. #10
    MS Excel MVP VBAX Regular Ken Wright's Avatar
    Joined
    Jun 2004
    Posts
    17
    Location
    Just for reference, in case you were going to use it in an array formula, the WEEKNUM() function doesn't play nice in Arrays :-)
    It's easier to beg forgiveness than ask permission

  11. #11
    VBAX Regular Juha_Antero's Avatar
    Joined
    Jan 2005
    Location
    Finland
    Posts
    8
    Location
    Thanks for that. I was just confused & surprised to learn that there are areas were Bill G does not provide for compliance with ISO...:-)

  12. #12

Posting Permissions

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