+ Reply to Thread
Results 1 to 8 of 8

format date cell with week number

  1. #1
    Forum Contributor
    Join Date
    01-06-2009
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    415

    format date cell with week number

    hello
    just wondering if its possible to format a cell to display date and week number
    and if so how to go about it

    eg

    04/01/09 week 1
    Last edited by excellentexcel; 01-08-2009 at 07:58 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    AFAIK -- no, you can't format a date value to show the week number via a Custom Format.

    You could use another cell referencing said date value:

    =TEXT(A1,"dd/mm/yy")&" Week "&WEEKNUM(A1,2)

    Where A1 holds date 4th Jan 2009

    WEEKNUM by default would use Sunday as start of week, by setting return type to 2 Monday becomes start of the week, ie the above returns Week1 whereas:

    =TEXT(A1,"dd/mm/yy")&" Week "&WEEKNUM(A1)

    would return Week 2.

  3. #3
    Forum Contributor
    Join Date
    01-06-2009
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    415
    hi donkeyote thanks for replying

    i tried your formula by jumping ahead a few years and it doesnt seem to follow

    i put in 27/09/2016 and it returns week 40
    when according to http://www.merlyn.demon.co.uk/week-cal.txt
    it should be week 39

  4. #4
    Forum Contributor
    Join Date
    01-06-2009
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    415
    its ok donkeyote
    found this on the net

    Please Login or Register  to view this content.
    from http://www.cpearson.com/excel/weeknum.htm

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    OK glad you have resolved - in Excel WEEK 1 commences from 1st Jan regardless of weekday of 1st Jan... so normally this is the issue for people... ie 1st Jan 2016 is a Friday so it's likely that with your data Week 1 commences on the 4th Jan... ie XL 1 too high.

    I will try and digest Chip Pearson's formula myself...

  6. #6
    Forum Contributor
    Join Date
    01-06-2009
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    415
    i just need to get that code to have the date infront of it

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Ah, ok, well it's pretty simple in truth just replace my formula with the one you found:

    =TEXT(A1,"dd/mm/yy")&" Week "&INT((A1-SUM(MOD(DATE(YEAR(A1-MOD(A1-2,7)+3),1,2),{1E+99,7})*{1,-1})+5)/7)

    Revision in red.

  8. #8
    Forum Contributor
    Join Date
    01-06-2009
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    415
    fantastic ty

+ 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