+ Reply to Thread
Results 1 to 9 of 9

Function that returns a week number

  1. #1
    Registered User
    Join Date
    11-08-2007
    Posts
    1

    Question Function that returns a week number

    Hi,
    Is there a function that returns the week number for a date?
    For example, if I enter 08/11/2007, the function will return week number 45.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    =WEEKNUM(A1)

    or

    =WEEKNUM("11/8/2007")

    HTH

    Jason

  3. #3
    Registered User
    Join Date
    10-22-2007
    Posts
    39
    Quote Originally Posted by jasoncw
    =WEEKNUM(A1)

    or

    =WEEKNUM("11/8/2007")

    HTH

    Jason

    Can you make it so it will put the current date inside the weeknum function? I want to calculate the current week of the fiscal year so I want it to do this =weeknum("Today's Date")-weeknum("06/01/07") Is this possible?

    Edit: Actually I just put weeknum(Today())-weeknum("06/01/07") and it seems to work, any reason why it wouldn't?
    Last edited by zb61; 11-11-2007 at 09:19 PM.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695
    Quote Originally Posted by zb61
    Edit: Actually I just put weeknum(Today())-weeknum("06/01/07") and it seems to work, any reason why it wouldn't?
    Yes, as of 1st January 2008 that will give you a negative number. How do you define your week numbers? Does week 1 always start on the 1st of June and last 7 days? If so you could use a formula like

    =INT((TODAY()-DATE(YEAR(edate(TODAY(),-5)),6,1))/7)+1

  5. #5
    Registered User
    Join Date
    10-22-2007
    Posts
    39
    Quote Originally Posted by daddylonglegs
    Yes, as of 1st January 2008 that will give you a negative number. How do you define your week numbers? Does week 1 always start on the 1st of June and last 7 days? If so you could use a formula like

    =INT((TODAY()-DATE(YEAR(edate(TODAY(),-5)),6,1))/7)+1
    The fiscal year always starts on the first friday of June. So how can I change the formula to reflect that?

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695
    Assuming A2 contains a date - if you want today's date then A2 should contain the formula =TODAY()

    =INT((A2-WEEKDAY(A2-5)-DATE(YEAR(EDATE(A2+1-WEEKDAY(A2-5),-5)),6,0))/7)+1

  7. #7
    Registered User
    Join Date
    10-22-2007
    Posts
    39
    Quote Originally Posted by daddylonglegs
    Assuming A2 contains a date - if you want today's date then A2 should contain the formula =TODAY()

    =INT((A2-WEEKDAY(A2-5)-DATE(YEAR(EDATE(A2+1-WEEKDAY(A2-5),-5)),6,0))/7)+1

    So all the A2's should be Today()'s ?

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695
    I'm suggesting that you put =TODAY in cell A2 (or any other cell) then it makes the formula a little shorter but it's also possible to use TODAY() in place of each instance of A2 in the formula, yes

  9. #9
    Registered User
    Join Date
    10-22-2007
    Posts
    39
    do I need to update that formula on year changes?

+ 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