As the formula is copied down, it returns the previous Sunday for each date shown in column B. See below to customize the formula to return different days of the week. Note: the formulas below use simple math to adjust the date. This works because Excel dates are large serial numbers.

### WEEKDAY solution

The WEEKDAY function accepts 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, but this is configurable, based on a second argument called return_type. In this example, because we want to roll back the date to the previous Sunday, we want to set WEEKDAY to return 1 for Monday and 7 for Sunday. To do this, we can use either 2 or 11 for return_type: Now that we have WEEKDAY returning 1 for Monday and 7 for Sunday, we can simply subtract the result from the given date: If the date is a Sunday, WEEKDAY will return 7. Subtracting 7 from the original date in B5 will return the previous Sunday. If the date is a Tuesday, weekday will return 2, moving the date back 2 days to Sunday. The formula works the same way for each day of the week.

### Other previous weekdays

In the above formula, you might wonder why we’re using 11 for return_type instead of 2? This is done for consistency To adapt the formula to return different previous weekdays, return_type needs to be adjusted Using 11 allows the different values to “line up” logically, as seen below: To be clear, using 2 instead of 11 for the previous Sunday will work just fine.

### CHOOSE function alternative

One feature of all formulas above is that they subtract days even when the given date is already the target weekday. In other words, if the date is already a Sunday, the result is the Sunday seven days prior. This isn’t always desired behavior. Sometimes, the goal is to leave the date alone if it’s already the right day of week. One way to accomplish this is with the CHOOSE function. The CHOOSE function is used to select values by numeric position. For example, if we have the colors “red”, “blue”, and “green”, we can use CHOOSE like this: The first argument is called index_num and specified the index of the value to return. We can combine CHOOSE and WEEKDAY to give us the correct “roll back” number like this: Here, the index_num argument is provided by the WEEKDAY function. Note WEEKDAY is in its default mode (no return_type provided), which returns 1 for Sunday and 7 for Saturday. The values that follow WEEKDAY are the actual rollback numbers. The first value is zero, which is the number of days to roll back if the date is already a Sunday. Putting the entire formula together, we get: This formula will return the previous Sunday unless the date is already a Sunday. In that case, CHOOSE will return zero and the formula itself will return the original date unchanged. To extend this idea to handle other days of the week, you can adjust the rollback numbers as needed for each day of the week like this: Alternately, you can adjust the formula to use a return_type argument in WEEKDAY and leave the rollback values alone: Again, the behavior of these formulas is the same as the original formula above except the rollback does not occur if the given date is already the target day of week.

### Custom number formatting

All dates in the example shown use the following custom number format: This number format displays a weekday abbreviation plus a date to make it easier to check results at a glance. The underlying date is unchanged.

### Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.