Insert week column in Excel - excel

I have a column in excel that has the day.
I want to add another column that will extract the week of that day (Mon-Sun) and display it as week ending on that Sunday's date.
Day
4/20/2019
4/21/2019
4/22/2019
4/23/2019
4/24/2019
4/25/2019
Expected Output
Day Week
4/20/2019 4/21/2019
4/21/2019 4/21/2019
4/22/2019 4/28/2019
4/23/2019 4/28/2019
4/24/2019 4/28/2019
4/25/2019 4/28/2019
Does anyone know how to add this column using excel functions?

WEEKDAY with the second parameter as 2 gives a number between 1 to 7 (7 being Sunday) for the day of the week. You can add to the date, the amount of days till that number becomes 7, in other words:
=A2+(7-WEEKDAY(A2,2))

Related

how to calculate the date from the year, week-of-year and day-of-week in EXCEL?

I have the Year, Week-of-Year and Day-of-the-Week as follows:
Year = 2022 (A2) ; Week Year = 35 (B2); Week Day = 4 or Thursday (C2)
and I would like to estimate the Date as dd.mm.yyyy, which is highlighted in yellow as it shows in the EXCEL picture.
I tried many formulas, but I am sure there might be an easy one.
I think you are counting the weeks starting from zero because for 9/1/2022 (YYYY/MM/DD format) the corresponding week is 36 as per the result of function WEEKNUM(DATE(2022,9,1)). In order to use the logic to multiply the number of weeks by 7. You need to use as a reference the first day of the year, if it was a Sunday, if not then go back to the previous Sunday, so you can count the entire week. Bottom line use as a reference date, the Sunday of the first week of the year, not the first day of the year (YYYY/1/1)
Here is the approach we use in cell E2:
=LET(y, A2:A6, wk, B2:B6, wDay, C2:C6, fDay, DATE(y,1,1), seq, SEQUENCE(7),
fDay - IF(WEEKDAY(fDay)=1,0, WEEKDAY(fDay,2)) + 7*wk
+ XLOOKUP(wDay, TEXT(seq,"dddd"), seq-1))
We use the LET function to avoid repeating the same calculation. The following expression finds the previous Sunday if the first day of the year (fDay) was not a Sunday:
fDay - IF(WEEKDAY(fDay)=1,0, WEEKDAY(fDay,2))
The XLOOKUP function is used to get the numeric representation of the weekday and use the TEXT function to generate the weekdays in a long format. Since we count the entire week, if the weekday is a Sunday (column C in my screenshot), then we don't need to add any day to our reference date, that is why we use seq-1.
Here is the output for several sample data. Assuming the week count starts with zero, if not the formula needs to be adjusted as also the input data.
Notice that the year 2021 started on a Friday, so if we want to find a day for the first week (0) before Friday it will return a date from the previous year. Like in the case of Monday. If you want an error message instead, then the formula can be modified as follow:
=LET(y, A2:A6, wk, B2:B6, wDay, C2:C6, fDay, DATE(y,1,1), seq, SEQUENCE(7),
result, fDay - IF(WEEKDAY(fDay)=1,0, WEEKDAY(fDay,2)) + 7*wk
+ XLOOKUP(wDay, TEXT(seq,"dddd"), seq-1),
IF(YEAR(result) <> y, "ERROR: Date from previous year", result))
I found the solution:
Year = 2022 (A2) ; Week Year = 35 (B2); Week Day = 4 or Thursday (C2)
=DATE (A2,1,3)-WEEKDAY(DATE(A2,1,3)) + 7 * B2 + C2 - 6
I found this solution, but you need to do further testing if it really works.
I calculate month from week: =+MONTH(DATE(YEAR(A2);1;1)+B2*7-1)
I calculate week day number from week day name: =MATCH(D2;{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"};0)
And then make date using: =DATE(A2;C2;E2)

Google Sheets or Excel Function to return date based on value

I have this table in Google Sheets (or excel). The year is the two last digit of my code.
Code Duration Months
1 AC-26482-17 60
2 AC-26482-18 30
3
I would like to return the date in this format (If no data, just leave blanks).
Code Duration Months Start Expiration
1 AC-26482-17 60 01/01/2017 01/01/2022
2 AC-26482-18 30 01/01/2018 01/07/2020
3
Is there a way to achieve this?
You mean you want to add the duration in months to the start date? If so, your sample has the wrong expiration date. 30 months added to 1/1/2018 is not June 1st, but July 1st.
The formula in Excel is
=EDATE(C2,B2)
If you also want to calculate the start date from the last two characters of the code, given all dates are in this millennium, then you can use this for the start date:
=DATE(RIGHT(A2,2)+2000,1,1)
edit: To handle blank cells, you can check with IsBlank()
=if(isblank(a2),"",DATE(RIGHT(A2,2)+2000,1,1))
use:
=ARRAYFORMULA(IF(A2:A="",,DATE(IF(RIGHT(A2:A, 2)*1>=40,,20)&RIGHT(A2:A, 2), 1, 1)))
=ARRAYFORMULA(IF(A2:A="",,DATE(YEAR(C2:C), MONTH(C2:C)+B2:B, 1)))

Excel Increment index by 1 for each new week

i have a calendar document which I use and in this document I have an index value which should add 1 for each new week. So week 1 has value 1, week 53 has value 53, then week 1 of the new year should have value 54. Any idea how i can achieve this ? I have dates available, as well as week of year as a value.
I solved it for the first year by using this formula but it's giving me trouble for the next years as it doesn't take into account the short weeks at the end of the year.
Here you see the problem: Week 1 of 2018 should have an index value of 107
Maybe start your count with 1 and then, starting from row 2, use the following formula:
=IF(OR(YEAR(A2)>YEAR(A1),WEEKDAY(A2)=1),B1+1,B1)
This should return the following results:

How to get week start and week end in excel for given month only

As I was new to excel, I am working on a use case where I want to get week start and week end dates of a given month,
I am using following formulae which is giving me next month date followed by weekend.
=A7+(6-WEEKDAY(A7,2)+1)
Week Start Week End
7/1/18 7/1/18
7/2/18 7/8/18
7/9/18 7/15/18
7/16/18 7/22/18
7/23/18 7/29/18
7/30/18 8/5/18
How can I modify or have a new formulae which gives me month end date, if my weekend is on next month
Expected output should be
Week Start Week End
7/1/18 7/1/18
7/2/18 7/8/18
7/9/18 7/15/18
7/16/18 7/22/18
7/23/18 7/29/18
7/30/18 7/31/18
For month like Feb as it is unable to caluculate the formula it should return 0
Week Start Week End
2/1/18 2/4/18
2/5/18 2/11/18
2/12/18 2/18/18
2/19/18 2/25/18
2/26/18 2/28/18
1/0/00 1/1/00
You just need to wrap the result of your original formula in MIN and compare it to EOMONTH.
=MIN(A7+(6-WEEKDAY(A7,2)+1), EOMONTH(A7, 0))
As far as Feb goes, you need to compare te current value with the one either above or below to determine whether month(date)<>month(date+7) and you have not shown enough of how your data structure transcends months to do that.

Find fourth Thursday each month and if NASDAQ closed that day, take next day

I am working in Excel where I need to find the fourth Thursday in each month but if on that day NASDAQ is closed take the day after. I have this formula for each fourth Thursday:
=DATE(YEAR(A2),MONTH(A2),CHOOSE(WEEKDAY(DATE(YEAR(A2),MONTH(A2),1)),26,25,24,23,22,28,27))
but I am not be to get the next business day where the fourth Thursday is any one of:
01-Jan-14
20-Jan-14
17-Feb-14
18-Apr-14
26-May-14
03-Jul-14
04-Jul-14
01-Sep-14
27-Nov-14
28-Nov-14
24-Dec-14
25-Dec-14
Please try appending to your formula:
+IF(OR(A2=41823,A2=41970,A2=41998),1,0)

Resources