Count the number of days from an end date for a given month

EmmaTM

Board Regular
Joined
Jan 5, 2022
Messages
74
Office Version
  1. 365
Platform
  1. Windows
Hi,
What would be the best formula to use in column L where I want to state the number of days for the given month = Q1 30/11/21
So all but cell L9 would be 30 as the end date is past 30/11/21 & L9 would be 18 as there are only 18 days of November left.
1641463693950.png


Thank you
 

Attachments

  • 1641463608771.png
    1641463608771.png
    15.9 KB · Views: 2
Yes I am making sure N2-P2 come back to D2 if C is N
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I was trying to give a clue

Excel Formula:
=IF(C2="Y",P2-D2,IF(C2="N",SUM(N2:P2)-D2))
 
Upvote 0
Is this it?

EmmaTM.xlsx
DEFJL
1AmountStart DateEnd DateTotal DaysDays in Period
2€ 250.0014-Mar-2113-Mar-2236530
3€ 516.0021-Sep-2124-Dec-219530
4€ 4,062.0001-Mar-2128-Feb-2236530
5€ 737.0001-Mar-2128-Feb-2236530
6€ 600.0001-Mar-2128-Feb-2236530
7€ 1,222.0001-Mar-2128-Feb-2236530
8€ 74.0001-Mar-2128-Feb-2236530
9€ 156.0019-Aug-2118-Nov-219218
10€ 715.0001-Feb-2121-Jan-2235530
11€ 664.0001-Nov-2131-Jan-229230
12€ 128.0001-Nov-2131-Jan-229230
13€ 2,234.0001-Apr-2230-Apr-223030
14€ 2,233.0001-Apr-2230-Apr-223030
15€ 432.0001-Jan-2101-Jan-21130
16€ 234.0022-Oct-2101-Dec-214130
17€ 929.0001-Jan-2030-Oct-2166930
2nd
Cell Formulas
RangeFormula
J2:J17J2=F2-E2+1
L2:L17L2=IF(AND($F2<=$Q$1,$F2>EOMONTH($Q$1,-1)),DAY($F2),DAY(EOMONTH($Q$1,0)))
I have now rolled this file over to the next month where the current period is now 31/12/21.
You see row 9 before we wanted column L9 to show 18 days, this is now showing as 31 when it should be 0.
The sum is:
=IF(AND(F9<=Summary!$K$2,F9>EOMONTH(Summary!$K$2,-1)),DAY(F9),IF(E9>Summary!$K$2,0,DAY(EOMONTH(Summary!$K$2,0))))

Note summaryK2 is the date 31/12/21

Also column K days past should be 92 as thats the total number of days for that item =IF(Summary!$K$1-E9<0,0,Summary!$K$1-E9+1)

1641565959625.png


I also need to revise the formula in column N as rows 14 & 15 should have a BF balance of £2,234 & £2,233.45.
It is currently
=D11/J11*K11
I tried =IF(K13="0",D13,IF(K13>0,(D13/J13)*K13))
But this is giving me FALSE, can you tell me what I have wrong with the formula?

Thank you
 

Attachments

  • 1641565695941.png
    1641565695941.png
    26.5 KB · Views: 1
Upvote 0
It appears the end of month date which started in AA1 then moved to Q1 is now in a seperate sheet called Summary in cell $K$2. You don't say what is in Summary $K$1 but I'll assume it's the 1st of that month, like this:
EmmaTM.xlsx
JKL
101-Dec-21
231-Dec-21
3
Summary
Cell Formulas
RangeFormula
K1K1=EOMONTH(K2,-1)+1


I've changed the Days in Period calculation as I now realize you want the count of how many days in the selected month are within the Start to End range.

I suspect you want the "Days Past" to be days between start date and the minimum of end date or end of month being accounted. I have changed the formula accordingly.

I suspect your Balance BF is to identify what amount of the contract has not yet been accounted for so it would be Amount divided by Total Days ($D2/$J2) multiplied by Total Days less Days Past ($J2-$K2). Let me know if that's wrong.

You don't say what your P&L or Balance CF calculations are but I'd like to see them as they need rounding to correctly perform the Ckeck column T.

Don't forget to test some items starting in 2022 with the "New Items"="Y" test.

EmmaTM.xlsx
CDEFJKLMNOPQT
1New ItemAmountStart DateEnd DateTotal DaysDays PastDays in PeriodDays PrepaidBalance BFP&LBalance CFCheck?
2N€ 250.0014-Mar-2113-Mar-2236526331?€ 69.86€ 21.23€ 49.32€ (109.59)
3N€ 516.0029-Sep-2124-Dec-21876424?€ 136.41€ 226.00€ 153.59€ 0.00
4N€ 4,062.0001-Mar-2128-Feb-2236527631?€ 990.46€ 111.00€ 2,960.54€ 0.00
5N€ 737.0001-Mar-2128-Feb-2236527631?€ 179.71€ 147.40€ 73.70€ (336.19)
6N€ 600.0001-Mar-2128-Feb-2236527631?€ 146.30€ 120.00€ 60.00€ (273.70)
7N€ 1,222.0001-Mar-2128-Feb-2236527631?€ 297.97€ 244.40€ 122.20€ (557.43)
8N€ 74.0001-Mar-2128-Feb-2236527631?€ 18.04€ 14.80€ 7.40€ (33.76)
9N€ 156.0019-Aug-2118-Nov-2192920?€ -€ 31.20€ 15.60€ (109.20)
10N€ 715.0001-Feb-2121-Jan-2235530431?€ 102.72€ 143.00€ 71.50€ (397.78)
11N€ 664.0001-Nov-2131-Jan-22923131?€ 440.26€ 132.80€ 66.40€ (24.54)
12N€ 128.0001-Nov-2131-Jan-22923131?€ 84.87€ 25.60€ 12.80€ (4.73)
13N€ 2,234.0001-Apr-2230-Apr-223000?€ 2,234.00€ (2,234.00)€ 2,234.00€ -
14N€ 2,233.0001-Apr-2230-Apr-223000?€ 2,233.00€ 446.60€ 223.30€ 669.90
15N€ 432.0001-Jan-2101-Jan-21110?€ -€ 86.40€ 43.20€ (302.40)
16N€ 234.0022-Oct-2101-Dec-2141411?€ -€ 46.80€ 23.40€ (163.80)
17N€ 929.0001-Jan-2030-Oct-216696690?€ -€ 185.80€ 92.90€ (650.30)
18N€ 323.0030-Nov-2105-Dec-21625?€ 215.33€ 64.60€ 32.30€ (10.77)
19N€ 221.0001-Nov-2101-Nov-21110?€ -€ 44.20€ 22.10€ (154.70)
4th
Cell Formulas
RangeFormula
J2:J19J2=F2-E2+1
K2:K19K2=IF(Summary!$K$1-$E2<0,0,MIN(Summary!$K$1,$F2)-$E2+1)
L2:L19L2=MAX(MIN(Summary!$K$2,$F2)-MAX(Summary!$K$1,$E2)+1,0)
N2:N19N2=($D2/$J2)*($J2-$K2)
T2:T19T2=IF($C2="Y",$P2-$D2,IF($C2="N",SUM($N2:$P2)-$D2))


It would be helpful if you could install XL2BB so we can better assist.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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