Help with a formula

Excelexcel86

Board Regular
Joined
Feb 28, 2023
Messages
99
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi guys someone very kindly managed to help me with the following formula =IF(MEDIAN(MOD(A1,1),TIME(6,0,0),TIME(14,30,0))=MOD(A1,1),"Y","N")

Now this works to an extent but my problem is instead of yes no I’ve I’ve changed the yes to B2-A2 this is because my cells contains dates and times in that are always different so if the two times in cell A and b are in between 06.00 and 14.30 it works but if cell b contains a different date the time formula don’t work as it goes to whatever time is in that cell and outputs the value below is an example of what is happening .so is there an And command I can use with this formula so it also looks to see if both dates are the same as well this would then work as both would be true
01/03/2023 06:3001/03/2023 13.306.00works fine
01/03/202301/03/2023 15:30Over work hours Works fine
02/03/2023 08:0003/03/2023 07:0023.00Don’t work because it’s gone over to 06:00 in the morning it’s calculate over the day
 
I'm afraid "it didn't work" does not give me very much to go on.

Here is what it looks like at my end.

20230305 Time worked in Work Hours Excelexcel86.xlsx
ABCDE
1time and date enteredtime exitedtotal item inside warehous hours Total time outside of warehouse hours Total Elapsed time calc For Checking
21/02/2023 7:001/02/2023 15:307.518.5
32/02/2023 8:303/02/2023 6:306.515.522
42/02/2023 8:305/02/2023 6:3023.546.570
53/03/2023 7:304/03/2023 8:309.515.525
Time Between Work Hrs Expanded
Cell Formulas
RangeFormula
C2:C5C2=24*IF(INT(B2)=INT(A2), MEDIAN(MOD(B2,1),TIME(6,0,0),TIME(14,30,0)) -MEDIAN(MOD(A2,1),TIME(6,0,0),TIME(14,30,0)), IF(INT(B2)-INT(A2)>=1, MEDIAN(MOD(B2,1),TIME(6,0,0),TIME(14,30,0))-TIME(6,0,0) +TIME(14,30,0)-MEDIAN(MOD(A2,1),TIME(6,0,0),TIME(14,30,0)) +(( INT(B2)-INT(A2)-1)*(TIME(14,30,0)-TIME(6,0,0))),""))
D2:D5D2=(B2-A2)*24-C2
E2:E5E2=(B2-A2)*24
On the same day between 07.30 and 23.20 it is giving me 12.45 hrs instead of 7hrs
Hi sorry it does work I’ve ran into a problem tho one of the days the work time hours are only until 11.30 not 14.30 I really appreciate your help so far
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I think that changes the question significantly and it would be better if you started a new thread. If you only ever spanned 2 days it wouldn't be too bad but we are allowing for it to span several days.
You might need a UDF (macro) to do the calculation.
I am assuming its a particular day of the week that is affected.
 
Upvote 0
Hi yes it’s a Friday so that formula works but if it goes to 14.30 on a Friday it calculates as 4hrs if it came in at 10.30
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

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