Note: In Excel's default scheme, weeks begin on Sunday. However, this example assumes the first day of a week is Monday, configured with WEEKDAY's second argument as explained below.
Imagine you have any random date and want find the Monday of the week in which the date appears. You can see you will need to "roll back" a specific number of days, depending on what day of the week the given date is. If the date is a Wednesday, you need to roll back 2 days, if the date is a Friday, roll back 4 days, and so on, as seen in the table below:
How can we figure out the the roll back number?
It turns out that the WEEKDAY function, with a small adjustment, can give us the rollback number we need. WEEKDAY returns a number, normally 1-7 for each day of the week. By setting the optional second argument (return_type) to 3, WEEKDAY will return numbers 0-6 for a Monday-based week. In other words, we can use WEEKDAY to generate the roll back values in the table above for any given date. Perfect.
The formula simply exploits this behavior directly:
This formula uses WEEKDAY to get an index for the day of week, and CHOOSE to fetch a roll back value. The advantage of this approach is that CHOOSE allows arbitrary values for each day of the week; you can customize as you like.
The WEEKDAY function returns a number, 1-7, that corresponds to particular days of the week. By default, WEEKDAY assumes a Sunday-based week, and assigns 1 to Sunday, 2 to Monday, and so on, with 7 assigned to Saturday. In this case, we only want to...
In Excel, the concept of "weekday" or "day of week" is based on the idea that each day of of the week has a specific number. With default settings, the WEEKDAY function treats Sunday as the first day of the week (1), and Saturday as the last day (7...
First, this formula determines the first day of the next month *after* a given date. It does this my using EOMONTH to get the last day of the month, then adding one day: = EOMONTH ( B5 , 0 ) + 1 Next, the formula calculates the number of days...
The DAY function returns the day value for a date. In the example show, the day value for the date in B5 (January 11, 2016) is 11. Because dates are just serial numbers in Excel, we can subtract 11, then add 1 to get the date value for January 1,...
The Excel WEEKDAY function takes a date and returns a number between 1-7 representing the day of week. By default, WEEKDAY returns 1 for Sunday and 7 for Saturday. You can use the WEEKDAY function inside other formulas to check the day of week...
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.