+ Reply to Thread
Results 1 to 18 of 18

Getting the date for the start of the week

  1. #1
    Registered User
    Join Date
    06-04-2008
    Posts
    28

    Getting the date for the start of the week

    I have this column with a value like 04/06/2008. I will want another of the column to auto generate the date for the start of the week like 02/06/2008 which is a Monday.

    How am I suppose to do this?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    =a1-weekday(a1,3)
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    Hmm but that does not seem to solve the problem to get the monday date of the week I keyed in the column.

    For instance,

    Column A: Column B:

    24/06/2008 22/06/2008
    25/06/2008 22/06/2008
    26/06/2008 22/06/2008
    27/06/2008 22/06/2008
    29/06/2008 29/06/2008
    30/06/2008 29/06/2008
    01/07/2008 29/06/2008

    Column A is the Date entered and Column B is the Date autogenerated when Column A is keyed in.

    How am I suppose to write the formula for column B?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    See attached, which includes your data and my formula in column C
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    May I ask the meaning of this formula?

    =A6-WEEKDAY(A6,3)

    I think I need change the formula to cater the start of week on Sundays instead of Mondays

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Direct from the help

    Return_type Number returned
    1 or omitted Numbers 1 (Sunday) through 7 (Saturday). Behaves like previous versions of Microsoft Excel.
    2 Numbers 1 (Monday) through 7 (Sunday).
    3 Numbers 0 (Monday) through 6 (Sunday).
    My formula gives you the Monday of that week, which is what you asked for.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    There maybe other formulas

    =IF(WEEKDAY(A1,3)=6,A1,A1-WEEKDAY(A1,3)-1)

  8. #8
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    Yr solutions solves 90% of my problem but there is a minor problem now.

    However, what I want now is Sunday instead of Monday of the week.

    This formula does not seem to apply if the date lands on Sunday itself, it returns back the previous week's Sunday after i change the formula to =A1-WEEKDAY(A1,2) for instance.

    What am I suppose to do in order to let the formula stick to not moving to previous sunday but stick to this same date if it land on sunday?

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    did you try the updated formula I posted?

  10. #10
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    I just used it and IT WORKS!! THNX SO MUCH!

  11. #11
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    Sry but I have another problem now.

    When the date is 01/01/2008, the formula provided generate out 30/12/2007. Is it possible for the first week of the year to take on the first day of the year?

    For instance, instead of 30/12/2007, I want it to generate 01/01/2008 instead. This only applies to the first week of the year only.

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Does this work for you?

    =IF(WEEKNUM(A1)=1,DATE(YEAR(A1),1,1 ),IF(WEEKDAY(A1,3)=6,A1,A1-WEEKDAY(A1,3)-1))

  13. #13
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    There seem to have an error with it

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    If it returns name then WEEKNUM is part of the analysis pak and you would need to load that addin.

  15. #15
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    Is there anyway instead of this formula then? Coz my this excel file will be shared and I do not want everyone to add this just for the sake of it.

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Try searching the forum for WEEKNUM and see is anybody has posted an alternative.

    Or you could make the formula more complicated by check the month and day of the date to see if it is January and less than 6 days.

  17. #17
    Registered User
    Join Date
    06-04-2008
    Posts
    28
    Any example of such formulas?

  18. #18

+ 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. week ending date?
    By SRussell in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-11-2008, 06:42 PM
  2. Week Date Function
    By gurpreet161 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-25-2008, 08:44 PM
  3. looping issues
    By Marcus Gee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-09-2007, 11:42 PM
  4. Statistical Anomalies
    By Gurblash in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-21-2007, 04:56 PM
  5. Assignment overDUE PLEASE PLEASE HELP!!
    By undergrad in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-29-2006, 12:34 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