How to get week number based on Two dates based Conditions in Excel - excel

I have a DateTime column in Excel in which data is sorted in ascending order based on DateTime conditions from 15th June to say 1st November ;
I want to print Week Number from 1st to Nth Week based on date condition; Week criteria are like first seven days i.e 15th June to 21st June is Week1, 22nd Jun-28th Jun is Week2, 29th June - 5th June is Week3 and so on.
How Can I do this?
Column1
06/15/2021 8:00
06/15/2021 10:00
:
:
11/01/2021 20:44
11/01/2021 20:46

Let's assume your list of dates is in A2:A.
Place the following formula in cell B2 of an otherwise empty range B2:B...
=ArrayFormula(IF(A2:A="",,ROUNDDOWN((INT(A2:A)-INT(A2))/7)+1))
INT is just removing the times from date-times.
The rest is really more of a math/logic question than a formula question.

Related

Find first date after today that matches a day-number and weekday

Given any date, how do I find the first month and year in the future where the 31st of that month falls on a Wednesday, in other words, for today, 11 November 2020, I would like to see (31) March 2021. [Updated: Returned month should be March 2021]
#prino,
You could make use of Excel's Iterative Calculation, setting Maximum Iterations to 1000.
In the example below, A1 is the given date and B1 receives the result (put the formula in B1):
=IF(B1=0,A1)+B1+IF(AND(WEEKDAY(B1,1)=4,DAY(B1)=31),0,1)
If you have Excel 365 then
=LET(DayInMonth, DATE(YEAR($A$2),MONTH($A$2)+SEQUENCE(336,,0,1),$B$2),
DOW, WEEKDAY(DayInMonth),
IsMatch, (DAY(DayInMonth)=$B$2)*(DOW=$C$2)*(DayInMonth>=$A$2),
XLOOKUP(1,IsMatch,DayInMonth,,0,1))
How it works:
Parameters are on the sheet (you could hard code these into the formula if you wish)
A2 is the start date (could be formula =TODAY())
B2 is the day number in the month
C2 is the day of week code (1..7 = Sunday..Saturday)
The calander repeats every 28 years. So only need to consider 12*28 = 336 months
DayInMonth is the specified date in each of the next 336 months, including this month. Note: if a month does not have the specified day (eg 31 September does'nt exist)
DOW is the day of Week code for those dates
IsMatch is 1 if calculated DayInMonth matches specified DayInMonth (this excluded non-existant dates) AND Calculated DOW matches specified DOW AND calculated date is on or after start date
XLOOKUP returns the date of the first 1 in the IsMatch array

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

how can i exclude FRI and SAT days from the calculation of days passed

I need to exclude FRI and SAT days from the formula which counts the days from date in cell A1 until the date of Today(), and subtracts A1 from Today()
i have already the formula which checks first if A1 has a value, if yes subtracts the value from Today(), if not it will say "NO VALUE"
i also know there is code to exclude FRI and SAT but i'm having a hard time incorporating it into my formula:
This will count 8 days from Start_Date in A1, and excludes FRI and SAT:
=WORKDAY.INTL(A1,8,7)
This is my current formula which shows the number of days, but i want it to skip FRI and SAT:
=IF((A1<>""),((TODAY()-A1)),"NO VALUE")
You can use NETWORKDAYS rather than WORKDAY:
=IF(A1<>"",NETWORKDAYS.INTL(A1,TODAY(),7),"NO VALUE")
It might not be the best way to do it but I found a work around.
You can calculate the total number of day and remove the number of Friday and remove the number of Saturday.
I found this that count how many Friday in a specific date range.
For example:
=SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(Date1&":"&Date2)))=5))
It basically retrieve all the date in the range in their numerical value and test if if it is a Saturday and give you the amount of Saturday between 2 dates.
In your case you could use it to remove the Friday and Saturday like below:
=IF((A1<>""),((TODAY()-A1-SUMPRODUCT(-(WEEKDAY(ROW(INDIRECT(A1&":"&B1)))=5)) -SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(A1&":"&B1)))=6)))),"NO VALUE")
Where B1 is today's date.
And example:
example using the formula
Hope this helps.

With having two dates now i month wise days calculation required

I have two dates. Now my aim is to calculate the number of days, month wise for n number of rows
Input:
start date 22/01/2019
finish date 21/06/2019
Output & result should be
January February March April May June
9 28 31 30 31 21
for many rows.
Excel or VBA Excel formula both will be great,
Thanks in advance....
Here is a screenshot of my Excel table:
https://ibb.co/tC38jzs
Here is a simple solution if your Active Month column entries are not the names of the month, but the last day.
31.01.2019 28.02.2019 ...
For the January column you can then use
=MAX(0, MIN($AV14-$AT14, AY$13-$AV14))
and for the other months you have to subtract the days aggregated since January. Here for February:
=MAX(0, MIN($AV14-$AT14, AZ$13-$AV14) - SUM($AY14:AY14))
Expand the last formula from Feb to Dec.

Calculating Based on an Array in Excel

I have a Pivot Table that I am able to cycle through the different months based on a Month Filter (changing the data of the table). I am trying to calculate based off of that change of value. I am recording the amount of times a license is used in a workday. The number of workdays in a month change based on the month. I calculated out the workdays for each month using
=NETWORKDAYS(H34,EOMONTH(H34,0),J34:J45)
H34 references my 1/1/2016 date. J34:J45 references my holiday dates to avoid.
I am trying to write a formula that says "If the month listed (from my month filter) within the Months list then to print the corresponding Workdays value.
=IF(G34:G46=H48, I34:I46)
It only works on January. The rest of the values return False. I do calculate it as an Array Function. It returns either False. I cannot think of another function that could replace it. Any help would be appreciated.
2016
Month Date Workdays Holiday Dates Holidays
January 1/1/2016 19 1/1/2016 New Year's day
February 2/1/2016 20 18-Jan Holiday 2
March 3/1/2016 22 2/15/2016 Valentines day
April 4/1/2016 21 3/25/2016 St. Patrick's Day
May 5/1/2016 21 5/30/2016 Memorial Day
June 6/1/2016 22 7/4/2016 Independence Day
July 7/1/2016 21 9/5/2016 Labor Day
August 8/1/2016 23 10/10/2016 Holiday
September 9/1/2016 22 11/8/2016 Columbus Day
October 10/1/2016 21 11/11/2016 Veteran's Day
November 11/1/2016 21 11/24/2016 Thanksgiving
December 12/1/2016 21 12/26/2016 Christmas
All 235
Selected Month
March FALSE
The VLOOKUP() function will greatly simplify this process for you. This particular function is great for extracting values in a list based on a key lookup field.
In your example, you want to easily extract the value from Holiday Dates column based on an input month.
A few things to keep in mind for the input parameter functions in this function:
The first column in your table array must contain the lookup value, in this case, the month column.
If may need to lock your array dimensions, use the $ sign in front of the column letter and row number.
FALSE should be selected for the range_lookup in order to do exact matching for the lookup value. If you choose false, you may get false positivies.
Every row in your list should be unique for the lookup value. Let's say January was listed twice, the value returned would be for the first occurrence.
Additional info:
http://spreadsheeto.com/vlookup/
http://www.howtogeek.com/howto/13780/using-vlookup-in-excel/
You can use the LOOKUP function, as follow:
=VLOOKUP(G48,G34:I45,3)
This formula looks up "G48" value in column G (first matrix column), and returns the value from column I (third matrix column) that is in the same row.
Read this official Office page for more details.
Please, give us your feedback.

Resources