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
 
@awoohaw, I think the OP has confirmed that you are spot on with your 3 step process and the comment relating to the 30 mins refers to my post since your 3 step process will pick it up.
As to your reference to the time before 6 am on the first day, see the OPs post #15 where an additional column has come to light which will cover off the extra hours outside of the work hours (Column Heading - "Total time outside of warehouse hours", presumably total time difference minus inside warehouse hours)
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
If start time on the first day is before 6:00 don’t include them but if they go into the next day count them like below example
Start time end time Time inside warehouse hours outside warehous hours
07.30 03/03/202308:30 04/03/2023So here the time should be the 6 hours up until 14.30 then it goes into the next morning so 06.00 till 08.30 is an extra 3.5 hrs so total should be 9.30 hours Here should have the total amount of hours including work hours so would be 25 hours
 
Upvote 0
Give this a try.

20230305 Time worked in Work Hours Excelexcel86.xlsx
ABC
1time and date enteredtime exitedHours In Area Decimal
21/02/2023 7:001/02/2023 15:307.5
32/02/2023 8:303/02/2023 6:306.5
42/02/2023 8:305/02/2023 6:3023.5
53/03/2023 7:304/03/2023 8:309.5
Time Between Work Hrs
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))),""))
 
Upvote 0
Hi are all these separate formulas or if and commands as I was hoping to highlight all cells and go down each one and the formula covers all basis?
 
Upvote 0
I don't understand the question.
It is a single formula that should cover the start and end dates being: on the same day or on the next day or several days later.
You put it on Row 2 and copy it down to all rows.
 
Upvote 0
Ok but I needed a formula to calculate the total time including the time outside of work areas as well that’s y I was say is there a and command to use with this formula
 
Upvote 0
I have logged off for the night.
Total time is (end datetime - start datetime)*24
Outside = Total time - Inside time as calculated by the formula I gave you.
 
Upvote 0
Ok thanks for you help but I put all of that formula in and it didn’t work
 
Upvote 0
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
 
Upvote 0
On the same day between 07.30 and 23.20 it is giving me 12.45 hrs instead of 7hrs
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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