+ Reply to Thread
Results 1 to 4 of 4

Get Date from Year, Week Number, and Weekday

  1. #1
    Registered User
    Join Date
    12-19-2019
    Location
    Southampton, England
    MS-Off Ver
    MS 365
    Posts
    7

    Get Date from Year, Week Number, and Weekday

    Hello all,
    I'm having an attempt at having a Date (1st, 2nd, etc.) output when the Year, Week Number, and Weekday are all inputted as a method to futureproof a staff rota I've created, as all that would have to change is the what's inputted into the year. I've tried to mess around with functions such as =WEEKDAY and =DATE, but I've hit a road block as I'm not exactly sure how I'd go about using them, and if they're the right functions for the job.

    Here is an example of the "logic" I'm trying to make this follow:
    CalculationExample.JPG

    And here is my Template for the staff rota:
    FinalTemplate.JPG

    Please let me know if you need any further information, and thank you in advance!
    Last edited by KingLudovic; 04-28-2021 at 04:16 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,848

    Re: Get Date from Year, Week Number, and Weekday

    You need to redesign your sheet. If you attach your actual file instead of just a picture I can help. See yellow banner at the top of the page.

    I am going to suggest you reverse your thinking. B3 should have a date which is the first Monday of the year (formula can be seen below). Then all other dates just add 1 to the previous date. You can still display the days of the week with format Dddd. For showing the date of the day, in B2 use =B3, and so forth. It is not worth your trouble to show ordinal dates. You have to deal with the following endings for seven different cases: st, nd, rd, th. You can see in H11 below how this is done. But don't bother. Just show the number of the date using format d.

    What you want is a very complicated formula. It would be very long. Here I show how to build it in steps. To make this one single formula would be very long and complicated.

    Values as displayed
    G
    H
    1
    Parameters:
    2
    Desired year
    2018
    3
    Week of year
    2
    4
    Desired day of the week
    Thursday
    5
    6
    Solution:
    7
    Date of the first of the desired year
    Monday, January 1, 2018
    8
    First Monday
    Monday, January 1, 2018
    9
    First Monday of week number
    Monday, January 8, 2018
    10
    Date of day of week
    Thursday, January 11, 2018
    11
    Day
    11th
    Underlying formulas
    G
    H
    1
    Parameters:
    2
    Desired year
    2018
    3
    Week of year
    2
    4
    Desired day of the week
    Thursday
    5
    6
    Solution:
    7
    Date of the first of the desired year
    =DATE(H2,1,1)
    8
    First Monday
    =DATE(H2,1,1)+7-WEEKDAY(DATE(H2,1,1),12)
    9
    First Monday of week number
    =H8+7*(H3-1)
    10
    Date of day of week
    =H9+MATCH(H4,{"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"},0)-1
    11
    Day
    =DAY(H10)&IF(OR(DAY(H10)={1,2,3,21,22,23,31}),CHOOSE(1*RIGHT(DAY(H10),1),"st","nd ","rd "),"th")
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    12-19-2019
    Location
    Southampton, England
    MS-Off Ver
    MS 365
    Posts
    7

    Re: Get Date from Year, Week Number, and Weekday

    That's exactly perfect for what I'm trying to do! Thank you so much for your help again, you've been a crucial part in making this.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,848

    Re: Get Date from Year, Week Number, and Weekday

    Glad to help, thanks for the rep!

+ 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] Updating week number, start date of the week, and year from a column date that's populated
    By Raylou in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-28-2020, 11:11 AM
  2. Replies: 5
    Last Post: 04-11-2017, 09:23 AM
  3. [SOLVED] Finding day date number from week and year data
    By gesaugen in forum Excel General
    Replies: 4
    Last Post: 01-10-2017, 09:48 AM
  4. [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
  5. Find date from year and week number
    By pnperl in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-17-2014, 04:04 AM
  6. formula/macro. How to convert data (weekday, week number, year) to a date?
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2011, 10:34 PM
  7. 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