Get next date from weekday in Google Sheets/Excel - excel

How can one return the next date of a given weekday (it could be either a number 1-7 or names Sunday-Saturday).
For example, if today, on Friday 16-Oct-2009 I passed in:
Friday, it would return today's date 16-Oct-2009
Saturday returns 17-Oct-2009
Thursday returns 22-Oct-2009
Here is the Spreadsheet
I have tried this formula:
=A12+(C12+ MOD(7-day(A12),7))

I worked out an answer to my own question
Here is the formula
=date(year(A12),month(A12), day(A12) + mod(C12+ 7-WEEKDAY(A12),7))

This worked for me:
=TODAY()+MOD(4 + 7-WEEKDAY(TODAY()),7)
Just replace TODAY() and 4 (weekday#) for your context.

This is the formula you are seeking.
=A12+(7-WEEKDAY(A12)+B12)
A12 holds the start date. B12 holds the ID of the targeted weekday, e.g. 1 for "Sunday".
A11 must hold a true date, as opposed to a text string that looks like a date. If the latter is the case an error will be displayed. The result is always a date. You can format that date as "dddd" to display a day's name or "dddd, dd-mm-yyyy" to display both date and day.
And here are the mechanics of the formula:- A12-WEEKDAY(A12) returns always the previous Saturday, a date that is always in the past. A12+(7-WEEKDAY(A12)) inverts that calculation, returning always the next Saturday. This date is always in the future except when A12 is a Saturday. That's when the result will be = A12.
Having found a stable base, you can just add the day you want to the Saturday you have. Add 1 (for Sunday) and you get a Sunday. Add 7 and you get a Saturday. All these dates will be in the future.
That's all as you want it except that if WEEKDAY(A12) = B12 you want the same date as in A12 which is a week earlier than the one the formula prefers. This is where I went wrong while in haste. My apologies! This is the correct modification of the formula's result, to wit, conditionally deduct 7 from the calculation.
=A12+(7-WEEKDAY(A12)+B12)-IF(WEEKDAY(A12)=B12,7,0)

Related

Finding data for a determined week

I have a table and I have a date in cell B4 which is something like 15/03/2021
I want to count values where the start date is the value on cell B4 but also count everything till the end of that week. So everything from Monday 15/03/2021 to Sunday 21/03/2021
What I have so far is something like
=COUNTIFS(MySheet!A:A,"Y",MySheet!C:C,">="&B4)
My trouble is how to tell it "also count everything until sunday that week without having to manually put the end date into a cell
Add 6 to the value in B4 to get the second criteria.
=COUNTIFS(Mysheet!A:A,"Y",Mysheet!C:C,">="&B4, Mysheet!C:C,"<="&B4+6)
I assume the question behind your question is how to account for dates in B4 other than a monday and keep counting untill the end of that same week, therefor you can use:
=COUNTIFS(Mysheet!A:A,"Y",Mysheet!C:C,">="&B4,Mysheet!C:C,"<="&B4+7-WEEKDAY(B4,2))
This does set a Sunday as the "end" of the week as per your OP.
Your question is slightly ambiguous, so there are two possible answers
To count for exactly 7 days:
=COUNTIFS(MySheet!A:A,"Y", MySheet!C:C,">="&B4, MySheet!C:C,"<"&B4+7)
To count until the end of the next Sunday: (N.B. On Sundays, this will only count 1 day)
=COUNTIFS(MySheet!A:A,"Y", MySheet!C:C,">="&B4, MySheet!C:C,"<"&B4+8-Weekday(B4,2))
This works by saying "on or after (>=) the date given", and "before (<) 7 days later / the following Monday"

How to auto populate the next week in excel

I am making an on-call schedule in excel and I can't for the life of me find an easy way to populate the dates. For example, someone is on call from Monday to Sunday, January 2nd - January 8th. Then the next person is on call from January 9th - January 15th. I am trying to figure out a way or formula to just "Drag" down the column and it input the next 7 day range. I have tried input the start date and end date in a separate cell, then using concatenate but it returns the date number in excel (forgot what its called). I also tried =(A1&" - "&B1) but that returns the same 5 digit number.
Any help or pointers are greatly appreciated!
Previous date + 7
If you have genuine dates, say in cells A1 "start date" and B1 "end date":
Jan 2 Jan 8
Then the next line will be
=A1+7 =B1+7
Verify Dates
To see, if the "Dates" you entered are realy dates excel can work with like that, apply "General formatting" to the A1 and B1 cells. If the resulting value is an Interer or a Decimal number, you are golden. If the resulting value did not change, you have a text and you need to apply different approach.
Perhaps you are looking for this:
=TEXT(A1,"d-mmm")&" - "&TEXT(B1,"d-mmm")
The formatting specification can be copied from the formatted cell properties.

Formula to return the next upcoming Thursday

I need an Excel formula that takes a given day and provides the next upcoming Thursday of that week. I have a list of dates with time stamp attached:
Date Week Ending
10/5/2015 10/8/2015
10/11/2015 10/15/2015
10/21/2015 10/22/2015
10/27/2015 10/29/2015
I want to convert it to the weekending. The example is of my date and the "Week Ending" I want the formula to show.
Assuming Date is in A1, if #Grade 'Eh' Bacon's solution is not working for you and given your mention of time stamp attached, maybe treat your dates as text and say, in B2 and copied down to suit:
=LEFT(A2,10)+(7-WEEKDAY(LEFT(A2,10),15))
Assuming your data is in A1, the formula is simply:
=A1+(7-WEEKDAY(A1,15))
Weekday(A1,15) gives the number of the day of the week of a given date, and the option ,15 says use a week starting with Fri and ending with Thurs. So, a given date, + (7-Weekday()) will give you the number of days required to get to the 'week ending with the Thursday on x date'.
If you want a Thursday to return the same date, then try:
=A1+7-WEEKDAY(A1+2)
The more generalized version would be:
=A1+7-WEEKDAY(A1+7-DOW)
where DOW (DayOfWeek) translates
Sun = 1
Mon = 2
...
Sat = 7

Excel: Convert calendar week (format ww.yyyy) into date

I need to convert an Excel calendar week date into the actual date.
Excel calendar week format = ww.yyyy (e.g. 31.2014);
Expected output = 7/28/2014 (return the Monday of the week)
What formula should I use ?
It's a bit of a pain: there's no direct function. If A1 contains the year, and A2 contains the week number then,
=MAX(DATE(A1,1,1),DATE(A1,1,1)-WEEKDAY(DATE(A1,1,1),2)+(A2-1)*7+1)
will return the date corresponding to the Monday of that week in that year.
To test it, use =WEEKNUM() and =YEAR() on the computed result, along with =TEXT(,"DDD") to prove it's a Monday.
If #Bathsheba's response works for you, you can do everything in cell B1 with the following command
=MAX(DATE(LEFT(B1,FIND(".",B1)),1,1),DATE(LEFT(B1,FIND(".",B1)),1,1)-WEEKDAY(DATE(LEFT(B1,FIND(".",B1)),1,1),2)+(MID(B1,FIND(".",B1)+1,2)-1)*7+1)
This allows you to put YYYY.WW in B1 and it splits it up for you in the calculation.

Check if any date within a range is within 1 month of todays date

I've got a column full of dates. How can I check that column to find which date is within a month of todays date, and then return it?
If there is no date within a month, just return blank
Lets say my dates are:
01-Jan-12
01-Apr-12
01-Jul-12
01-Oct-12
01-Jan-13
The code im using is below. A:A is the range of the dates above
=MIN(IF(A:A>TODAY(),A:A))
The issue im having is that if I use the above, it returns 01/01/12 and not 01/01/13. Also, if I change the dates so the next date is December 1st 2012, it still returns 01/01/12
So you really just want the earliest date if that's within a month? If so perhaps try
=IF(MIN(A:A)-TODAY()<=30,MIN(A:A),"")
Assumes dates in column A
If you have past and future dates try this formula
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=TODAY()+30,A2:A100)),1),"")
confirmed with CTRL+SHIFT+ENTER
or for exactly 1 month (rather than 30 days) try using EDATE, i.e.
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=EDATE(TODAY(),1),A2:A100)),1),"")

Resources