Math with Time

nikneven

Board Regular
Joined
Mar 20, 2006
Messages
117
ok, so in my spreed sheet i need cell to do some time calculations. Basically it is payroll for employees. They get paid overtime for everything between midnight and 6am. its set up like this...

A1 is the Start Time
A2 is the Duration
T1 needs to be number of hours worked between 6am and 11:59 pm
T2 needs to be number of hours worked between 12:00am and 5:59 pm

so, if

A1 =4 PM
A2= 10
then i need a formula to make T1 = 8 and T2 = 2

and the kick, it needs to span days, so if
A1=10pm
A2=10
T1=4
T2=6.
Get it?
help! Excels date and time stuff boggles my mind...

thanks
nik
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
Hi nik,

assuming A1 contains a valid time, e.g. 10 pm or 22:00 etc. and A2 is 18 or less then try this formula in T2

=IF(A1+A2/24<1,MAX(0,MIN(6,A1*24+A2)-A1*24),MIN(6,MOD(A1*24+A2,24)))

and this in T1

=A2-T2
 

nikneven

Board Regular
Joined
Mar 20, 2006
Messages
117
will that not work for anything over 18? sometimes it goes up to twenty.
 

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
I was trying to avoid overcomplicating the formula but to accommodate up to 20 hours change formula in T2 to this

=IF(A1+A2/24<1,MAX(0,MIN(6,A1*24+A2)-A1*24),MIN(6,MOD(A1*24+A2,24))+MAX(0,6-A1*24))
 

Forum statistics

Threads
1,136,345
Messages
5,675,225
Members
419,555
Latest member
Paddington

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
Top