Solved

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

Posted on 2014-12-10
2
223 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 500 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA 4 27
Excel Formula 16 45
Excel filter on tab not showing any entries? 5 22
Declaring dynamic table and naming it . 2 20
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 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