Calculate total hours between two dates and times

Krupsdahl

New Member
Joined
Dec 12, 2012
Messages
33
Hi all..

I hope you can help me with this.. I have attached a test worksheet I did. But it seems that I got something wrong.. Or like I did it in a stupid way.

I was hoping that you could help me calculate the total hours spent away from my home, so I can put it in my sheet and turn in to my accountant..

So for instance if I left home at 10.00 the 28/2/16 and returned the 3/3/16 at 12.00 it should count 98 hours in column L. Be aware that not all months have the same length.

You do not need to concern about CVR, PLACE, TOTAL DISTANCE, EARNINGS, TRAVEL HOURS and FAKTURA NR..

CVR:Start date:Place:Total Distance (km):Earnings:Travel hours:Start time:End date:End time:Calc.Calc.Total hoursFaktura nr.:Diæt:
*13. juni 2016Rasmus Walter - Produktionsøver Portalen Greve53,24.000,00 kr108.0013. juni 201623.000,015,015,01620
*18. juni 2016Rasmus Walter - Knuthenborg Safari Live2904.000,00 kr3,512.0018. juni 201622.000,010,010,01630
*24. juni 2016Rasmus Walter - Karolinelunden Ålborg829,24.000,00 kr810.0025. juni 201608.000,022,022,01640
*20. juli 2016Musik i Lejet603.000,00 kr116.00##8,00,064,01651256
*21. juli 2016Musik i Lejet03.000,00 kr0###24,00,070,01651373,75
*22. juli 2016Musik i Lejet03.000,00 kr0###24,00,056,01651099
*23. juli 2016Musik i Lejet603.000,00 kr1##08.008,00,00,01650
*28. juli 2016Turboweekend - Svendborg1663.000,00 kr210.00##14,00,00,01660
*29. juli 2016Turboweekend - Grim Festival4873.000,00 kr5#30. juli 201610.0010,00,00,01670
*6. august 2016Rasmus Walter - Ringsted Festival1314.000,00 kr208.006. august 201617.000,09,09,01680
0,00,00,01690

<tbody>
</tbody>

This is the formulas I created

Column J=IF(AND(G2="#";H2="#";I2="#");24;IF(AND(H2="#";I2="#");24-G2*24;IF(G2="#";I2*24;0)))
Column K=IFERROR(IF(H2>B2;(I2-G2)*24+24;(I2-G2)*24);0)
Column L=IF(AND(OR(G3="#");OR(G4="#";H4="#";I4="#"));J2+K2+J3+J4+J5;K2)
Column N=IF(L2>=24;471/24*L2;0)

<tbody>
</tbody>


Best Regards, Tim
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Are your dates numerical dates or text dates? You will need to make them numeric. Then just add the end date & time and delete the start date and time then multiply by 24.
 
Upvote 0
Hi Tim,

I've come up with a possible solution - not particularly neat but it works.

I custom formatted a new cell as hh:mm dd/mm/yy and entered time of departure as, say 08:00 1/7/16 and using the same cell format for return time e.g. 15:00 3/7/16 and in another cell, formatted as [hh];mm, subtract the departure cell from the return cell.

HTH.

Mel
 
Upvote 0
Hi Tim,

After some pondering, I think I understand your data now. The problem you have is totalling up in column L; I assume you're happy with your calculations for J and K. Here's what I had in L2 copied down and I did actually use column M in order to determine whether it's part of the same total:

=SUMPRODUCT(--($M$2:$M2=$M2),$J$2:$J2+$K$2:$K2)

Alternatively you could use a couple of SUMIFs:

=SUMIF($M$2:$M2,$M2,$J$2:$J2)+SUMIF($M$2:$M2,$M2,$K$2:$K2)

WBD
 
Upvote 0
HI Guys.

Thank you for the replies.. I am not sure I can use either of your solutions. The whole meaning is that I want the start date, end date, start time, end time in 4 different columns.. and I want a clear calculation that counts the total hours.. and only in integers ( whole hours ) my two columns named Calc. and Calc. as well as total hours, i am not sure the formula is right...unfortunately
 
Upvote 0
HI Guys.

Thank you for the replies.. I am not sure I can use either of your solutions. The whole meaning is that I want the start date, end date, start time, end time in 4 different columns.. and I want a clear calculation that counts the total hours.. and only in integers ( whole hours ) my two columns named Calc. and Calc. as well as total hours, i am not sure the formula is right...unfortunately

Did you try my solution? Is it not working for you?

WBD
 
Upvote 0
Wideboydixon. The problem is it is wrong colums, so i am not sure which ones you intended to use..

If you count my columns I have N columns in my test sheet.. can you redo that formula then ?
 
Upvote 0
HI Guys.

Thank you for the replies.. I am not sure I can use either of your solutions. The whole meaning is that I want the start date, end date, start time, end time in 4 different columns.. and I want a clear calculation that counts the total hours.. and only in integers ( whole hours ) my two columns named Calc. and Calc. as well as total hours, i am not sure the formula is right...unfortunately

For the most part the calculation is straight forward, but the display(formatting) gets some people. Use the [h] in the formatting of the time.
You can round to the appropriate Hour after converting from Date/Time Serial number (ROUNDUP, ROUNDDOWN or MROUND)
=(EndDate+EndTime)-(StartDate+StartTime)
 
Upvote 0
Wideboydixon. The problem is it is wrong colums, so i am not sure which ones you intended to use..

If you count my columns I have N columns in my test sheet.. can you redo that formula then ?

Did you try my formula in cell L2 and then copy it down? I tested on a copy of your sheet that I created. Apologies that I had to re-format the dates and numbers:


Book1
ABCDEFGHIJKLMN
1CVR:Start date:Place:Total Distance (km):Earnings:Travel hours:Start time:End date:End time:Calc.Calc.Total hoursFaktura nr.:Dit:
2*13-Jun-16Rasmus Walter - Produktionsver Portalen Greve53.24,000.00 kr108:0013-Jun-1623:000.015.015.01620
3*18-Jun-16Rasmus Walter - Knuthenborg Safari Live2904,000.00 kr3.512:0018-Jun-1622:000.010.010.01630
4*24-Jun-16Rasmus Walter - Karolinelunden lborg829.24,000.00 kr810:0025-Jun-1608:000.022.022.01640
5*20-Jul-16Musik i Lejet603,000.00 kr116:00##8.00.08.01650
6*21-Jul-16Musik i Lejet03,000.00 kr0###24.00.032.0165628
7*22-Jul-16Musik i Lejet03,000.00 kr0###24.00.056.01651099
8*23-Jul-16Musik i Lejet603,000.00 kr1##08:008.00.064.01651256
9*28-Jul-16Turboweekend - Svendborg1663,000.00 kr210:00##14.00.014.01660
10*29-Jul-16Turboweekend - Grim Festival4873,000.00 kr5#30-Jul-1610:0010.00.010.01670
11*06-Aug-16Rasmus Walter - Ringsted Festival1314,000.00 kr208:0006-Aug-1617:000.09.09.01680
Sheet1
Cell Formulas
RangeFormula
J2=IF(AND(G2="#",H2="#",I2="#"),24,IF(AND(H2="#",I2="#"),24-G2*24,IF(G2="#",I2*24,0)))
K2=IFERROR(IF(H2>B2,(I2-G2)*24+24,(I2-G2)*24),0)
L2=SUMPRODUCT(--($M$2:$M2=$M2),$J$2:$J2+$K$2:$K2)
N2=IF(L2>=24,471/24*L2,0)


WBD
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

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