count time

JOEE1979

Active Member
Joined
Dec 18, 2022
Messages
292
Office Version
  1. 365
Platform
  1. Windows
07:00-15:00 (this is whats in cell D8)
This represents the time my worker is supposed to be at work.
I cannot change this format.
Is there a formula I can write to count the amount of hours worked?

Thank you
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
=(MOD(TEXTAFTER(D8,"-")-TEXTBEFORE(D8,"-"),1))*24
I modified the formula to look like this
=IFNA((MOD(TEXTAFTER(B9,"-")-TEXTBEFORE(B9,"-"),1))*24,"0")

is there a way to make the formula auto count all the cell in column B?
 
Upvote 0
Try this and you should be able to drop your IFNA too:
=IF(B2:B100="",0,(MOD(TEXTAFTER(B2:B100,"-")-TEXTBEFORE(B2:B100,"-"),1))*24)
 
Upvote 0
I modified the formula to look like this
=IFNA((MOD(TEXTAFTER(B9,"-")-TEXTBEFORE(B9,"-"),1))*24,"0")
Given that your time format looks like it is probably uniform, then for a single cell, another option might be
Excel Formula:
=IFERROR(MOD(RIGHT(B9,5)-LEFT(B9,5),1)*24,0)

.. or for the whole column
Excel Formula:
=IFERROR(MOD(RIGHT(B2:B100,5)-LEFT(B2:B100,5),1)*24,0)

If your times never span midnight then the formulas could be a bit shorter again.
 
Upvote 0

Forum statistics

Threads
1,223,530
Messages
6,172,843
Members
452,484
Latest member
vmexwindy

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