Convert Week NUM to the Week Beg date in Excel - excel

I have the below formula to give me the week ending of a week num, how can I get the date of the week beginning from this?
=DATE(YEAR(TODAY()),1,1)+(7-WEEKDAY(DATE(YEAR(TODAY()),1,1))-6)+(A2*7)
when A2 is 10 for example and B2 is the date.
thanks

Are your weeks ISO weeks? If so then that formula might work for this year but it will be wrong in 2016 because it will give the end date of week 1 as 3rd Jan when it should be 10th Jan
I would use this formula for start date (a Monday)
=DATE(YEAR(TODAY()),1,A2*7-2)-WEEKDAY(DATE(YEAR(TODAY()),1,3))
then just add 6 for the end date
=DATE(YEAR(TODAY()),1,A2*7+4)-WEEKDAY(DATE(YEAR(TODAY()),1,3))

Related

Excel Formula for finding if the 16th lands on a Saturday or Sunday and if it does, returning the date of the following Monday

Imagine that in cell A1 you have the first day of the month. I need a formula that finds if the 16th day of that month falls on a weekend (Saturday or Sunday) and if that is the case, return the date of the following Monday. If the 16th is not on a weekend, it will just return the date of the 16th
=If( (A1 + 15) = Saturday or Sunday, Date of the next Monday, (A1 + 15) )
I apologize in advance for my formula being terrible, I'm at a loss on this one.
For example, if A1 = "10/1/2019" then the forula will return 10/16/2019 because the 16th is not a weekend. However, is A1 = "11/1/2019" then the formula will return 11/18/2019 because the 16th is a Saturday. Thanks!
You can use the WEEKDAY function to determine the day of the week.
=IF(WEEKDAY(A1+15,2)=6,A1+17,IF(WEEKDAY(A1+15,2)=7,A1+16,A1+15))
The workday function is probably the easiest way to do this:
=WORKDAY(A1+14,1)
A1+14 --> the fifteenth of the month
We then add one workday. If that added workday falls on a Sat or Sun (or optional holiday if you want to do that), the weekend days will be skipped, otherwise the 16th will be returned.

How to identify the week within a month with criteria in Excel

How can I calculate the week of the month? I understand that with the WEEKNUM function and ISOWEEKNUM function I can get the week of the year but this is not what I am looking for.
A week has only 4 weeks so the function must look at a date written in a cell and only identify a week 1-4
There is one set of criteria that I found especially difficult to add:
Week 1 for July 2019 begins on June 30th - Ends on July 27th
Week 1 for August begins on July 28th - Ends on August 24th
How can something like this added to an excel function?
This formula calculates a week in month (assuming your have a date at A1 cell)
=WEEKNUM(A1,2)–WEEKNUM(DATE(YEAR(A1),MONTH(A1),1),2)+1
Use WEEKNUM to get the week of year.
Use WEEKNUM to from the date of the first day of the month the date falls within.
Subtract the two week numbers (add 1 in case result is 0 - first week in month).
Sample:
8/21/2019
=WEEKNUM(A1,2) -> 34
WEEKNUM(DATE(YEAR(A1),MONTH(A1),1),2) -> 31
34-31 = 3 -> third week of August

excel date from week number and year

I have the following table in Excel that has year number and week number:
Year Week
----- ------
2015 33
2014 41
2016 40
How can I get a 3rd column that has the date of the corresponding Friday for each row? So, week 33 of 2015 should return: Friday, August 14, 2015.
I have tried to use the date function, weeknum function, but cannot get any consistent results.
If you are using ISO week numbers then this formula will give the date you want
=DATE(A2,1,B2*7+2)-WEEKDAY(DATE(A2,1,3))
where year is in A2 and week number in B2
Format in required date format
With ISO week numbers week 1 always starts on the first Monday on or after 29th December
Assuming the week starts on Sunday and non-ISO week-numbering, the date of the Sunday of Week#1 of any year is given by:
=CHOOSE(WEEKDAY(DATE(A2,1,1)),DATE(A2,1,1),DATE(A2,1,1)-1,DATE(A2,1,1)-2,DATE(A2,1,1)-3,DATE(A2,1,1)-4,DATE(A2,1,1)-5,DATE(A2,1,1)-6)
Then add 5 to move to Friday. Then add:
(B2-1)*7
to advance to the proper week:
=CHOOSE(WEEKDAY(DATE(A2,1,1)),DATE(A2,1,1),DATE(A2,1,1)-1,DATE(A2,1,1)-2,DATE(A2,1,1)-3,DATE(A2,1,1)-4,DATE(A2,1,1)-5,DATE(A2,1,1)-6)+5+(B2-1)*7

How to calculate the number of weeks between 2 date range in excel

I have a question here, I have 3 columns in excel, A1 is being the calendar date; column B1 has the fiscal_quarter_start_date ; and fiscal_quarter_end_date in column C1.
I am trying to find the number of week falling in between the A2 and A3. The issue here is I should consider the first sunday as the first week of the quarter. My fiscal year starts on Feb of every month.
The reason I am doing this calculation is to populate the count of weeks numbers of a quarter, where my first week starts from the first sunday of the quarter.
=ROUNDUP(MOD(IF(A13>=IF(DATE(YEAR($A13),2,1)=1,DATE(YEAR($A13),2,1),DATE(YEAR(A13),2,7-WEEKDAY(DATE(YEAR(A13),2,1),1)+2)),ROUNDUP((A13-IF(WEEKDAY(DATE(YEAR(A13),2,1),1)=1,DATE(YEAR($A13),2,1),DATE(YEAR($A13),2,7-WEEKDAY(DATE(YEAR($A13),2,1),1)+2))+1)/7,0),ROUNDUP((A13-IF(DATE(YEAR($A13)-1,2,1)=1,DATE(YEAR($A13)-1,2,1),DATE(YEAR($A13)-1,2,7-WEEKDAY(DATE(YEAR($A13)-1,2,1),1)+2))+1)/7,0)),13.01),0)
above is the formula i've got all the way. However rounding up with 13 is not a viable solution as its not necessary that it should have always have 13 weeks all the time.
For example: 5/1/16 should be week 1 As it is a begging of a q2 and 5/1/16 is the starting on Sunday. In this case using above formula result for the week is 13
Please help me..
You can use WEEKNUM to get the week number.
However you mentioned that your week wont end at the Saturday, but at the Sunday, so you have to do =WEEKNUM(<insert here where the date is>,2)
=WEEKNUM (serial_num, [return_type])
serial_num - A valid Excel date in serial number format.
return_type - [optional] The day the week begins. Default is 1.
Return_type can either be 1 or 2:
1 - Week begins on Sunday
2 - Week begins on Monday
or... read it here for counting weeks between 2 dates.
Enter this formula =(A2-A1)/7 into a blank cell, (A2 indicates the end date and A1 is the start date)
If you just want to get the whole weeks, please apply this INT function: =INT((A2-A1)/7)
Try it here, on sheet "week"
Hope it'll help.
Assuming that the Quarter start and end dates are in A3:A6 respectively then:
=IF(AND(C1>=$A3,C1<$A4),WEEKNUM(C1)-WEEKNUM($A3)+1,IF(AND(C1>=$A4,C1<$A5),WEEKNUM(C1)-WEEKNUM($A4)+1,IF(AND(C1>=$A5,C1<$A6),WEEKNUM(C1)-WEEKNUM($A5)+1,WEEKNUM(C1)-WEEKNUM($A6)+(IF(AND(C1>=DATE(YEAR(C1),1,1),C1<DATE(YEAR(C1),MONTH($A6),DAY($A6))),53,1)))))
This is checking whether the date in the cell above (C1) is between the quarter start and end dates, and checking the difference in weeks from the start date. To cover the anomoly for Q4 extending into the next year, the IF statement at the end adds 53 instead of 1 for the affected dates.
Edit #1
=WEEKNUM(A1)-WEEKNUM(B1)+IF(AND(A1>=DATE(YEAR(A1),1,1),A1<DATE(YEAR(A1),MONTH(B1),DAY(B1))),53,1)
This works for the A1:C1 format you mentioned in your comment. Obviously this relies on B1 and C1 being updated manually.
Edit #2
=WEEKNUM(C1)-WEEKNUM(B1)
If you are counting 05/01/2016 as week 1 then add 1 to the result. Take off the highest week number (default is counting from sunday or you can change to (C1,1) if you want to define it exactly) from the lowest week number. Reult is 13 which would match the manual calculation.
You will want to look at the previous edit for an example of the if formula you will need when the quarter ends in another year. to reverse the negative figure it will need to add 52 when the date is in the early part of the next year and 0 when it is not.
You can use the "hidden" function DATEDIF:
For example in A1 we write start date (01/05/2016), in B1 - end date (31/07/2016) and in C1 = DATEDIF(A1,B1,"d")/7 the result will be 13

Excel Formula: Current 12 months

I'm looking for a formula in excel that will give me a current 12 month table. For example this month is April. I want a formula that gives me 12 months back from April in the exact format as show in the table below. For next month it will be May, and 12 months back from may without having to adjust any dates.
Month
5/1/2015
6/1/2015
8/1/2015
9/1/2015
10/1/2015
11/1/2015
12/1/2015
1/1/2016
2/1/2016
3/1/2016
4/1/2016
Thank you
Try this and copy down 11 rows
=EDATE((TODAY()-DAY(TODAY())+1),ROW(A1)-12)
If you number the months in column b starting from b2 =0 to b13=11
And row 1 has headers
A2 formula =EOMONTH(today(),b2-1)+1
A3 formula = EOMONTH(today(),b3-1)+1
Etc.
EOMONTH will give you the last day of any month. So if we start with today() it will give you the last day of the current month, but if we count back 1 month (b2-1). It will give you the last day of last month. So we add 1 day to it and you get the first day of each month.
Hope this helps :)

Resources