Sumifs Hours Worked Between Two Dates and Times with Multiple Criteria

bradyman97

Board Regular
Joined
Feb 22, 2008
Messages
60
Office Version
  1. 2019
Below is a small sample of my spreadsheet. I'm trying to come up with a formula that adds the total hours worked between two dates, and the times are between 2200 and 0600, and if my code is Overtime 1.5. Formula result should be 16 hours.


(A1) Start Date "01/01/2024"
(A2) End Date "01/04/2024"
(A3) Code Name "Overtime 1.5"
(C1) Total Hours for the Code


DATERATECODESTARTENDTOTAL HOURS
01/01/202433.67Normal Hours14:0022:008.00
01/01/202450.51Overtime 1.522:0006:008.00
01/02/202433.67Normal Hours14:0022:008.00
01/03/202450.51Overtime 1.506:0014:008.00
01/03/202433.67Normal Hours14:0022:008.00
01/04/202433.67Normal Hours14:0022:008.00
01/04/202450.51Overtime 1.522:0006:008.00



Thank you for your time
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
How about
Fluff.xlsm
ABCDEFGHI
1DATERATECODESTARTENDTOTAL HOURS
201/01/202433.67Normal Hours14:0022:00801/01/202416
301/01/202450.51Overtime 1.522:0006:00804/01/2024
402/01/202433.67Normal Hours14:0022:008
503/01/202450.51Overtime 1.506:0014:008
603/01/202433.67Normal Hours14:0022:008
704/01/202433.67Normal Hours14:0022:008
804/01/202450.51Overtime 1.522:0006:008
9
Sheet6
Cell Formulas
RangeFormula
I2I2=SUMIFS(F:F,A:A,">="&H2,A:A,"<="&H3,C:C,"overtime 1.5",D:D,TIME(22,0,0),E:E,TIME(6,0,0))
 
Upvote 0
Solution
How about
Fluff.xlsm
ABCDEFGHI
1DATERATECODESTARTENDTOTAL HOURS
201/01/202433.67Normal Hours14:0022:00801/01/202416
301/01/202450.51Overtime 1.522:0006:00804/01/2024
402/01/202433.67Normal Hours14:0022:008
503/01/202450.51Overtime 1.506:0014:008
603/01/202433.67Normal Hours14:0022:008
704/01/202433.67Normal Hours14:0022:008
804/01/202450.51Overtime 1.522:0006:008
9
Sheet6
Cell Formulas
RangeFormula
I2I2=SUMIFS(F:F,A:A,">="&H2,A:A,"<="&H3,C:C,"overtime 1.5",D:D,TIME(22,0,0),E:E,TIME(6,0,0))

I see the formula works on your sheet but I can't figure out why it's not working on my sheet.


=SUMIFS(Timesheet[TOTAL HOURS],Timesheet[DATE],">="&'Pay_Statement (2)'!B2,Timesheet[DATE],"<="&'Pay_Statement (2)'!B3,Timesheet
Code:
,"Overtime 1.5",Timesheet[START TIME],TIME(22,0,0),Timesheet[END TIME],TIME(6,0,0))
 
Upvote 0
In what way isn't it working?
 
Upvote 0
I have my date range from 12/25/2022 to 1/7/2023 and on 1/6/2023 I worked overtime from 22:00 to 0600 and it's not calculating that date. IF I change say 1/3/2023 to overtime from 22:00 to 06:00 it calculates it right but for some reason it's not on 1/6/2023
 
Upvote 0
I have my date range from 12/25/2022 to 1/7/2023 and on 1/6/2023 I worked overtime from 22:00 to 0600 and it's not calculating that date. IF I change say 1/3/2023 to overtime from 22:00 to 06:00 it calculates it right but for some reason it's not on 1/6/2023
It's giving me a result of zero
 
Upvote 0
Do any of the dates also include the time?
 
Upvote 0
In that case make sure that all the dates are real dates & not text. The same goes for the times.
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,968
Members
449,095
Latest member
Mr Hughes

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