+ Reply to Thread
Results 1 to 20 of 20

Receive a date range if I have week number and year

  1. #1
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Receive a date range if I have week number and year

    In Cell F1 I have March 2015. In cell F2 I have the week number of that specific month. In cell F4 I would like to return the date range, ex. (March 9, 2015 - March 13, 2015.) It is important to tie to cells F1 and F2, as I have data validation drop boxes on the month and week that will correspond with the rest of the data. I have read of doing this if you have the week number of the year, but I need to be able to do this with the week number of the month (Monday to Friday.) Is this possible?

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Receive a date range if I have week number and year

    Is 1st March 2015 the only day in Week 1 of that month, or does Week 1 start on Monday 2nd March 2015?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    I have this formula in place on my data sheet to calculate the week number of the month:

    =WEEKNUM(B2,2)-WEEKNUM(DATE(YEAR(B2),MONTH(B2),1),2)

    This formula will return a number 0-5. "0" is returned for an instance such as and entry January 1st or 2nd. I add plus 1 to the end of the formula to push those values to the next week (week 1). Same goes for an instance such as March 30th and 31st. All other instances fall under a full Monday to Friday. For instances where I add or minus one from the above formula, I would need the returned date range to include those dates. So if I ran this report on January 9, the week would be considered week 1 and the returned values would be "January 1, 2015 - January 9, 2015. For an instance such as the end of March, I would want "March 30, 2015 - April 3, 2015" The all other weeks would be the Monday to Friday date.

    I hope this helps! Im pretty good in Excel but this one is driving me crazy. Any help is appreciated

  4. #4
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    to clarify- For March 30 and 31st I actually subtract 4 to pull it into week one of the next month. I have attached the file for your reference. Any help or direction is appreciated!
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Rowley
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: Receive a date range if I have week number and year

    Not sure if this will work for you, but try this:

    =MAX(DATE(F1,1,1),DATE(F1,1,1)-WEEKDAY(DATE(F1,1,1),2)+(F2-1)*7+1)

    Cell F1 should be only the YEAR,
    Cell F2 should be the Week Number

    So if F1 = 2015
    and if F2 = 12 ( Week Number 12 )
    then you should get the Date of: Monday, March 16, 2015

  6. #6
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    Thank you but this formula would only work with the week number of the year. I need it to work for the week number of the month..

  7. #7
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Receive a date range if I have week number and year

    Please find the file attach, hoping the best

    see you
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    Thank you Azumi, this is the closest ive got to a solution, but this formula works for only a few months. if you change the date to april 2015, it the formula falls apart

  9. #9
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    so when the box reads april 2015 week 1, i would need the dates to return March 30, 2015 - April 3, 2015...formula also breaks for january 2015....

  10. #10
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Receive a date range if I have week number and year

    Yep sorry about that, gotta fix them, hope this works now
    Attached Files Attached Files
    Last edited by azumi; 03-21-2015 at 09:33 PM.

  11. #11
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    Thank you Azumi but still a little off...week 1 for march 2015 pulls february dates..i feel like its so close please help me!

  12. #12
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Receive a date range if I have week number and year

    Seems correct now, Im tes with random number of month and weeks, this my last try...
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    You sir are brilliant. Thank you very much.

  14. #14
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Receive a date range if I have week number and year

    Ahhh... glad it works

  15. #15
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    Hi Azumi, I hope all is well. I was hopin gfor some help on a formula if you have time. If you reference the sheet you attached on this thread on 3/22, I want to do the opposite. Rather then plug a week number in cell B2 to return the date range, I want to plug just a date,(not a date range) in and have the formula spit out the week number of the month. Can you please help? Here is what I came up wth but it breaks for date like 3/30, and 3/31...

    =IF(WEEKNUM(B2,2)-WEEKNUM(DATE(YEAR(B2),MONTH(B2),1),2)=0,1,IF(WEEKNUM(B2,2)-WEEKNUM(DATE(YEAR(B2),MONTH(B2),1),2)=5,1,(WEEKNUM(B2,2)-WEEKNUM(DATE(YEAR(B2),MONTH(B2),1),2))))

  16. #16
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Receive a date range if I have week number and year

    Im confused what you after now, let me clarify you have date on both cells A2 and B2, and what the results? The week number?

  17. #17
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    I have 1 date, I need week number of that month for that specifc date. So in your spreadsheet, if the date I have fell in between the dates ranges in A9 and B9, the returned value would be the month and week number of month...(April20151)...Month is April, 2015 is year, 1 is week number

  18. #18
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,731

    Re: Receive a date range if I have week number and year

    Quote Originally Posted by Moosey71889 View Post
    In Cell F1 I have March 2015. In cell F2 I have the week number of that specific month. In cell F4 I would like to return the date range, ex. (March 9, 2015 - March 13, 2015.)
    It seems like you are defining week 1 of each month as starting with the Monday on or immediately before 3rd of the month, in which case you can use this formula to get the date range for that week

    =TEXT(F1-4-WEEKDAY(F1+1)+F2*7,"mmmm d, yyyy - ")&TEXT(F1-WEEKDAY(F1+1)+F2*7,"mmmm d, yyyy")

    To reverse that and get the week number (of the month) from a date in B2 use this formula:

    =INT((6+DAY(B2+5-WEEKDAY(B2-1)))/7)
    Audere est facere

  19. #19
    Registered User
    Join Date
    03-20-2015
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    18

    Re: Receive a date range if I have week number and year

    Thank yuou for the response..Not quite what I am looking for. This looks like its on the right track, but it breaks for dates like january 27 or march 31. It returns a 5. I would need a date like march 31st to be considered as part of week 1 for april. any ideas?

  20. #20
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,731

    Re: Receive a date range if I have week number and year

    Quote Originally Posted by Moosey71889 View Post
    It returns a 5.....
    Not for me, do you mean for 2015?

    If I have 31-Mar-2015 in B2 then this formula....

    =INT((6+DAY(B2+5-WEEKDAY(B2-1)))/7)

    ....gives me 1

+ 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. [SOLVED] Get the date of saturday in a week from a week number / year
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2015, 06:56 PM
  2. Find date from year and week number
    By pnperl in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-17-2014, 04:04 AM
  3. [SOLVED] Determine Week Start Date From Year And Number
    By SalientAnimal in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-23-2013, 07:51 AM
  4. Replies: 6
    Last Post: 05-08-2013, 01:46 PM
  5. Replies: 1
    Last Post: 08-23-2005, 11:42 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