?
Solved

Can I get a formula for identifying the date of the last day of the week?

Posted on 2014-12-10
2
Medium Priority
?
244 Views
Last Modified: 2014-12-10
I would like to run a formula across a spreadsheet to breakup data into weekly segments for a pivot table. I want to graph that data by the date of the last day for a week.

I want to make a week equal to Monday - Sunday. I can do this with a Weeknum function below.

Example:
=WEEKNUM("1/1/14", 2) to get a value of "1"

Question:
I need help with a formula where the value would represent the date of the Sunday at the end of the week. So in the example above, the result of "1" would be equal to 1/5/14. I would like to use this formula across a lot of data for an entire year so an ability to fill down is desired.
0
Comment
Question by:Brad Rubin
2 Comments
 
LVL 3

Accepted Solution

by:
Richard Obenchain earned 2000 total points
ID: 40492897
You don't need the week function to do it.

WeekDay([cell],2) will return the Monday-Sunday day of the week (1-7).  So, you do:

=[cell]+(7-WEEKDAY([cell],2))

... where [cell] is your reference date.  This will look at the current date, figure out how many days it is to the next Sunday, and then add that number of days.

If you want to be absolutely sure you never get a time value added (so that it's just the date part), you can do:

=date(year([cell]+(7-WEEKDAY([cell],2))),month([cell]+(7-WEEKDAY([cell],2))),day([cell]+(7-WEEKDAY([cell],2))))

or more simply:

=date(year([cell]),month([cell]),day([cell]))+(7-WEEKDAY([cell],2))
0
 
LVL 4

Author Closing Comment

by:Brad Rubin
ID: 40492909
Much appreciated...worked well.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question