
Tips.Net > ExcelTips Home > Worksheet Functions > Date and Time Functions > Calculating Week-Ending Dates
Summary: When working with dates, you may need to figure out all the dates on which weeks end in a given year. There are several formulaic ways to accomplish this task, as described in this tip. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)
Do you keep track of information based on week-ending dates? Many businesses do, and therefore need a quick way to calculate the week-ending dates for the complete year. The dates could be easily calculated with a macro, but you can do it just as easily with formulas.
There are two formulas you can use in order to calculate your week-ending dates. Let's assume, for the sake of this example, that your year is stored in cell A1. You could then figure out the first Saturday of the year by using this formula in cell A3:
=DATE(A1,1,1)+7-WEEKDAY(DATE(A1,1,1))
This works because the WEEKDAY function returns a value of 1 (Sunday) through 7 (Saturday) for any date. If you subtract that value from 7, then you have a value of 6 (Sunday) through 0 (Saturday). When you add that value to the DATE value for January 1 of the year, you end up with the first Saturday of the year.
If you prefer to have your weeks end on Fridays, then the formula needs to change a bit:
=DATE(A1,1,1)+7-(WEEKDAY(DATE(A1,1,1)+1))
Finally, if you prefer to have your weeks end on Sundays, then the formula needs to be like this one:
=DATE(A1,1,1)+7-WEEKDAY(DATE(A1,1,1),2)
This formula uses a parameter for the WEEKDAY function that calculates weekdays that range from 1 (Monday) through 7 (Sunday).
Once you have the first week-ending date for the year (in A3, remember?), then you can calculate the rest of the week-ending dates for the year. Place the following formula in cell A4:
=IF(YEAR(A3+7)=$A$1,A3+7,"")
This checks to see if one week past the previous date is still in the year. If it is, then the new date is returned. If it isn't, then an empty string is returned. If you copy this formula from A4 down through A55, then you will have all the desired week-ending dates for the year. With the formulas in place, simply change the year in cell A1 to see how the dates change.
The range A3:A55 provides room for 53 week-ending dates, which is possible for any given year. Because you used the IF statement in the formula in cells A4:A55, then the very last value (A55) will be blank if there were only 52 week-ending dates for the year.
Tip #2444 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
PivotTables Got You Perplexed? ExcelTips: PivotTables for the Faint of Heart shows how you can start using Excel's PivotTable tool right away to spin your data into gold! You discover how easy it really is to crunch the numbers you need to crunch. Uncover the power of the PivotTable Wizard, how to edit PivotTables, how to format them, how to customize them, and much more.
Check out ExcelTips: PivotTables for the Faint of Heart today!
Thousands of ExcelTips, available for immediate download. Have all the Microsoft Excel info you need, right at your fingertips. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site