Sum hours per day between dates

nemmi69

Well-known Member
Joined
Mar 15, 2012
Messages
938
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
I have seen the formula to sum between dates but I need to generate a total of hours (End_Time-Start_Time) for each of the days between two dates. IE 24/11/2022 to 25/11/2022 from a table like the one below
1669797353594.png
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Do you want an additional column with the difference ?
Do any of the End_Times run into the next day ie past midnight ?
What is the name of your table ?
 
Upvote 0
See if this is what you had in mind.

20221130 Hours calculation nemmi69.xlsx
ABCD
1
2DateStart_TimeEnd_TimeHours
324-Nov8:009:001
424-Nov9:0013:004
524-Nov13:0015:002
624-Nov15:0018:003
724-Nov18:0018:450.75
824-Nov18:4519:150.5
924-Nov23:450:150.5
Sheet1
Cell Formulas
RangeFormula
D3:D9D3=ROUND( IF(MOD([@[End_Time]],1)<MOD([@[Start_Time]],1), (1+MOD([@[End_Time]],1)-[@[Start_Time]])*24, ([@[End_Time]]-[@[Start_Time]])*24), 2)
 
Upvote 0
Thank you but the From and To dates will change and it will only be the individual days between those dates IE 24/11/2022 to 25/11/2022
Date Hours
24-Nov 11:15
25-Nov 10:00
 
Upvote 0
A variety of solutions for you. It would be much better if you posted an extract of your data and expected results with the forum's tool named XL2BB!

Time.xlsm
ABCDEFGH
24DateStartEnd
2524 Nov08:0009:0024 Nov11:1511:15
2624 Nov09:0013:0025 Nov14:4014:40
2724 Nov13:0015:00
2824 Nov15:0018:00
2924 Nov18:0018:45
3024 Nov18:4519:15
3125 Nov08:0009:00
3225 Nov10:1523:55
5b
Cell Formulas
RangeFormula
G25:G26G25=SUMPRODUCT(--($A$25:$A$32=F25),$C$25:$C$32-$B$25:$B$32)
H25:H26H25=SUM(IF($A$25:$A$32=F25,$C$25:$C$32-$B$25:$B$32))


Time.xlsm
ABCDEFGH
1DateStartEndTime sum
224 Nov08:0009:0001:0024 Nov11:15
324 Nov09:0013:0004:0025 Nov14:40
424 Nov13:0015:0002:00
524 Nov15:0018:0003:00
624 Nov18:0018:4500:45
724 Nov18:4519:1500:30
825 Nov08:0009:0001:00
925 Nov10:1523:5513:40
10
11DateStartEndExcel enters the formulas use Data Subtotal
1824 Nov Total11:15
2125 Nov Total14:40
22Grand Total25:55
5b
Cell Formulas
RangeFormula
G2:G3G2=SUMIFS($D$2:$D$9,$A$2:$A$9,F2)
D2:D9D2=C2-B2
D18D18=SUBTOTAL(9,D12:D17)
D21D21=SUBTOTAL(9,D19:D20)
D22D22=SUBTOTAL(9,D12:D20)
 
Upvote 0
Looks good Dave, but the dates will be selected by user so need to be able to dynamically change.
 
Upvote 0
I can manage it if someone can figure how to get from the From to dates in B1 & B2 to the dates in E2 to E5 so that if a wider range is entered it will expand to cover

1669809387248.png
 
Upvote 0
Sorted!!

1669813082114.png

Table name "TblDiary" in Sheet "DiaryPage"

1669812906015.png


1669812942650.png

Sheet name "Results"

AB4 =DATEVALUE($B$3)
AB5, AB6 . . . =IF($B$3+ROW(A1)<=DATEVALUE($B$4),AB4+1,"")

AC4, AC6 . . . =IF(AB4<>"",IF(SUMIFS(TblDiary[Start_Time],TblDiary[Date],"="&Results!$AB4)<=0,"",SUMIFS(TblDiary[Start_Time],TblDiary[Date],"="&Results!$AB4)),"")
AD4, AD6 . . . =IF($AB4<>"",IF(SUMIFS(TblDiary[End_Time],TblDiary[Date],"="&Results!$AB4)<=0,"",SUMIFS(TblDiary[End_Time],TblDiary[Date],"="&Results!$AB4)),"")
AE4, AE6 . . . =IF($AB4="","",AD4-AC4)
AF4, AF6 . . . =IF($AB4="","",IF(AE4<$AG$2,(AE4-$AG$2)*-1,AE4-$AG$2))
 

Attachments

  • 1669813203034.png
    1669813203034.png
    69.6 KB · Views: 2
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,608
Members
449,174
Latest member
ExcelfromGermany

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