Count # of days that fall within time period, but restrict based on conditions

lzcrss2

New Member
Joined
Aug 3, 2016
Messages
11
Hi there,

I have a list of 247 weeks in chronological order. They do not align with the calendar weeks. I need to count the # of days that fall within the first week of the calendar month OR the last week of the calendar month.

For example, the first week in my list is 01/06/13 - 01/12/13. This week would be assigned a 2 for # of days that fall within the first week of the calendar month (01/06/13 and 01/07/13), and a 0 for # of days that fall within the last week of the calendar month. There are more examples in the table below. I need a formula in the second 2 columns to calculate these # of days automatically. I've done it once before, but I lost the spreadsheet and apparently have become dumber over time. Help!

First Day of WeekLast Day of Week# of "First Week of Calendar Month" days# of "Last Week of Calendar Month" days
01/06/1301/12/1320
01/13/13

<tbody>
</tbody>
01/19/13

<tbody>
</tbody>
00
01/20/13

<tbody>
</tbody>
01/26/13

<tbody>
</tbody>
02
01/27/13

<tbody>
</tbody>
02/02/13

<tbody>
</tbody>
25
02/03/13

<tbody>
</tbody>
02/09/13

<tbody>
</tbody>
50
02/10/13

<tbody>
</tbody>
02/16/13

<tbody>
</tbody>
00
02/17/13

<tbody>
</tbody>
02/23/13

<tbody>
</tbody>
02
02/24/13

<tbody>
</tbody>
03/02/13

<tbody>
</tbody>
52
03/03/13

<tbody>
</tbody>
03/09/13

<tbody>
</tbody>
50
03/10/13

<tbody>
</tbody>
03/16/13

<tbody>
</tbody>
00
03/17/13

<tbody>
</tbody>
03/23/13

<tbody>
</tbody>
00
03/24/13

<tbody>
</tbody>
03/30/13

<tbody>
</tbody>
0

<tbody>
</tbody>
6

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
First column :
=IF(DAY(A2)<=7,8-DAY(A2),IF(DAY(B2)<=7,DAY(B2),0))

Last column :
=IF(DAY(EOMONTH(A2,0))-DAY(A2)<7,DAY(EOMONTH(A2,0))-DAY(A2)+1,IF(DAY(EOMONTH(B2,0))-DAY(B2)<7,DAY(B2)-DAY(EOMONTH(B2,0))+7,0))
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,799
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top