Formula to calculate a days pay depending on the date range - excel

I am working a sick leave pay schedule. The issue i am having is that we pay in 2 different ways; for every month , EXCEPT February, a days pay is worked out using ( in my sheet ):
B21/365*P28 (where B21 = annual salary and P28 = number of days)
However, i would like to create a formula that differentiates when a person was sick during February and pay the February days at a rate of
B21/12/28*P28
I assumed it would be a simple if(and()) but i cannot get it work.
My dates of sick leave are added between F28 ( start) -G28 (end).
I would like it to know when a date is in Feb and count that many days at the Feb rate, and also count the other days at the normal rate.
As an example, if a person is ill between the 25th of January and 5th of February i'd like to pay 7 days at the normal rate, and 5 days at the February rate automatically. Cell S28 is where the payment appears.

Option 1 - Include Weekends
I used this formula in D2 (and drag down):
=SUMPRODUCT(--(MONTH(ROW(INDIRECT(A2&":"&B2)))=2)
And E2 is simply:
=(B2-A2+1)-D2
Option 2 - Exclude Weekends
Use the following formulas:
=SUMPRODUCT((MONTH(ROW(INDIRECT(A2&":"&B2)))=2)*(WEEKDAY(ROW(INDIRECT(A2&":"&B2)),2)<=5))
and
=NETWORKDAYS(A2,B2)-D2

Related

How to calculate accumulated vacation days in Excel based on days (and hours) worked per month?

TLDR: I need a way to track date values in a dynamic calendar and count the days I've worked on on a monthly base.
So I've made a dynamic calendar (in the 1904 Date system to enable negative time handling) to help me track days and hours worked in Excel that has some automatic features. I would now like to add a calculator to calculate the accumulation of vacation days based on the following conditions:
Days worked per month >= 14
OR
The total hours worked per month >= 35
If one or both of these conditions are met I will receive 2 vacation days (2.5 after the 1st year of employment) and the accumulated vacation days should be shown in a single cell C7 (see picture for reference).
I know that I need to calculate the days that I've worked on on a monthly base and compare the result to the 1st condition (and the same for the worked hours and compare the result to the 2nd condition, but the solution for that is much the same as for the 1st condition). I've made my calendar in a way that I can't use fixed cells to do the calculation, as the length of the calendar is fixed to 53 full weeks and the dates change to accommodate the length according to the year in cell C2 i.e. January 1st will not always be in cell D17. Here are the first 10 rows of my dynamic calendar in Table Markdown format with the formulas as asked.
Year
2023
Quota
=SUM(J11:J375;'2022'!C2)
Hours per week
37.5
Gross working days
=NETWORKDAYS(DATE(C2;1;1);DATE(C2;12;31);'1pyhapaivat'!B7:B21)
Net working days
=COUNTIF(H11:H381;">0")
Vacation Accumulation
Kilometers per day
36
Week No.
Date
Day
Start
end
Hours
Sum
Quota
Kilometers
Holidays
Note
=ISOWEEKNUM(D11)
=SEQUENCE(371;1;DATE($C$2;1;1)-WEEKDAY(DATE($C$2;1;1);2)+1;1)
=D11
=IF(M11="quota";-7,5/24;IF(G11>F11;IF((G11-F11)>(6/24);(G11-F11)-(0,5/24);(G11-F11));""))
=SUMIF(H11:H15;">0")
=I11-COUNTA(G11:G15)(($C$4/5)/24)-COUNTIF(M11:M15;"quota")(($C$4/5)/24)
=COUNTA(F11:F15)$C$8-(SUM(COUNTIF(M11:M15;"Remote");COUNTIF(M11:M15;"Office"))$C$8)
=XLOOKUP(D11;_1pyhapaivat3[Start Date];_1pyhapaivat3[Subject];"")
A snippet of the dynamic calendar
I've tried combining the DATE and SUM functions with other functions like COUNTA, and COUNTIF. I've also tried using different LOOKUP functions but to no avail.
The new dataset filtered by Year
And filtered again by Month

Is there a way to set monthly deductions on a value?

This is for personal budget and savings within an excel sheet.
Say I have a loan of £1000, I will be paying £10 per month as of 7th December 2019 until the amount is paid off.
I would like to have a summary page on my sheet displaying the current outstanding debt. Currently I can only seem to work out how to deduct the £10 if date greater than/ equal to 7th. Which is not useful as each month after the 7th it'll display £990.
What about DATEDIF:
=1000-((DATEDIF(43806,TODAY(),"M")+1)*10
Where:
1000 - Your starting loan
DATEFIF - Function to calculate difference between two dates in months
43806 - 1st Parameter: Starting date > 7th December 2019
TODAY - 2nd Paremter: Volatile function to feed the second parameter with current date
M - 3rd Parameter: Calculate difference in whole months
+1 - Amount of months + 1 to account for all payments
*10 - Difference in months times 10 to deduct from starting loan
This would be volatile though, so use sparsely.

Using Excel to calculate multiple future dates

I am working on a revenue report that predicts deposit date related to "Revenue Date" based on observed patterns. For example, one stream of revenue is always deposited the next business day, so I would need a formula that adds one day to anything with a "Revenue Day" identified as Monday through Thursday (because these would be deposited Tuesday-Friday, respectively), and adds three days to a "Revenue Day" identified as Friday (because this would be deposited on Monday), and adds two days for Saturday, and one for Sunday.
I managed to get the correct result for Monday-Thursday using this formula, where G1 is the weekday and H1 is the date:
=IF(OR(G1="MONDAY", G1="TUESDAY", G1="WEDNESDAY", G1="THURSDAY"), H1+1)
Unfortunately, I can't figure out how to also get it to add 3 days to Friday, 2 days to Saturday, and 1 day to Sunday. Is this possible?
Your if formula should take 3 parameters IF(condition, do if condition is true, do if condition is false).
Use ; instead of ,
Sundays does the same this as Moday-Thursday, so no need for a special case for it
... So i would guess that you need something like this :
=IF(OR(G1="SUNDAY";G1="MONDAY";G1="TUESDAY";G1="WEDNESDAY";G1="THURSDAY");H1+1;IF(G1="FRIDAY";H1+3;IF(G1="SATURDAY";H1+2;"bad input")))

Count number of hours between 2 dates excluding weekends and between 10pm - 10am?

I'm trying to calculate the number of hours between two date/times, excluding bank holidays and between 10pm and 10am.
I've got the Start Datetime in B3, and then End Datetime in G3. In SLA B13 - B22, I have a list of the bank holiday dates for 2015, and I am using the following forumal
=SUM(G3-B3-COUNTIFS(SLA!B13:B22,">"&B3,SLA!B13:B22,"<"&G3))
For some reason, I cant get this to exclude bank holidays, however I then also nee to take into account the 10pm - 10am bracket.
Can anyone help?
=NETWORKDAYS(B3;G3;SLA!B13:B22)*12
*12 because only 12 hours per day count (exclude time between 10 pm and 10 am)
I've tried your formula and it works fine for whole days for me, as long as you format the cell containing the formula as general or number to avoid formatting it as a date. It doesn't exclude weekends of course which presumably is what you want.
You might want to add 1 to make it inclusive, make > into >= and < into <= in case the start and end dates are bank holidays and multiply by 12 to get the result in hours:-
=(G3-B3+1-COUNTIFS(SLA!B13:B22,">="&B3,SLA!B13:B22,"<="&G3))*12
You could calculate the hours worked directly from datetime values: the basic formula would be:-
=(G3-B3)*24-(INT(G3)-INT(B3))*12
i.e. subtracting 12 hours for each complete day.
You could also exclude the holidays (if between the start and end dates):-
=(G3-B3)*24-(INT(G3)-INT(B3)+COUNTIFS(SLA!B13:B22,">"&B3,SLA!B13:B22,"<"&G3))*12
i.e. subtracting a further 12 hours for each day's holiday.
One more thing you could do is to apply an adjustment for start and end time to the Networkdays formula by adding:-
=MOD(G3,1)-MOD(B3,1)

Excel - Times a month and day occur between 2 dates

I have an Excel sheet where someone types in the date for a yearly bill. I need to know how many times we need to pay that bill between 2 dates.
For example if a bill is due every year on May 31st, the user will type in 5/31/2014. I need to know how many time we will pay that bill between 5/15/2014 and 5/15/2018. (The between dates will change). I can't just take the number of years between the start and end dates because in the example above the start and end dates could be 6/1/2014 and 5/30/2018, in which case I only have to pay the bill in 2015, 2016, and 2017, which makes 3 times.
I have this formula which calculates the number of times a certain day occurs between 2 dates: SUMPRODUCT(--(DAY(ROW(INDIRECT($Q$2&":"&$R$2)))=F4))(Q2 is the begin date, R2 is the end date, and F4 has the day of the month) But I can't figure out how to get this to work for a month and day.
Assuming the specific date in G4 you can use this version
=SUMPRODUCT(--(TEXT(ROW(INDIRECT($Q$2&":"&$R$2)),"ddmmm")=TEXT(G4,"ddmmm")))

Resources