Help with difference between 2 dates including am/pm and check multiple entries to see if they occur at the same date and am/pm

KHaynes42

New Member
Joined
Feb 20, 2024
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi, I'm looking for help calculating differences between dates and then checking multiple lines of data to see if they occur during the same period.

Each line of data represents a repair job, each with a start date and completion date formatted in dd/mm/yyyy hh:mm:ss.
A day consists of 2 periods, one am and one pm session.
Firstly I need to be able to calculate the number of sessions between the 2 dates.
Secondly I then need to be able to check if that date and session appears in another line of data as that will change my ultimate financial calculation.

Example of the sheet attached.
Column C is the first date, Column E is the completed date. My current formula to calculate the difference is in column L but this isn't taking into account the am/pm sessions so in the example of line 5, it's showing 14 sessions but this should be 13 as the job wasn't logged until the pm.

Those that then show as 'fail' in column J need to be checked against all other failing lines to see of they occur at the same time and session.

Any help greatly appreciated

Thank you!
Sample data.xlsx
BCDEFGHIJKLMNOPQR
2Ratchet - Performance Points
301.251.5
4Task RefLogged DateDue FixCompleted DateSLA RefZonePerformance/AvailabilityPass/FailAreaContract SessionsZone CategoryPerformance Points (per Contract Session)Performance Points (total)0 to 56 to 1011 upwards
5204541313/12/2023 13:43:0020/12/2023 13:43:0004/01/2024 14:03:203.7CirculationPerformanceFailZonal14Circulation25431.25125156.25150
6206094420/12/2023 15:00:0008/01/2024 12:00:0008/01/2024 11:00:002.2aCirculationPerformancePassWhole School0Circulation550.00000
7207705604/01/2024 10:59:0012/01/2024 17:00:0004/01/2024 14:04:443.7Classrooms PracticalPerformancePassZonal0Classrooms- Practical250.00000
8207706304/01/2024 11:02:0012/01/2024 17:00:0004/01/2024 14:05:223.7Admin, Management, GuidancePerformancePassZonal0Admin , Management , Guidance250.00000
9207712104/01/2024 11:05:0012/01/2024 17:00:0005/01/2024 06:38:153.7Admin, Management, GuidancePerformancePassZonal0Admin , Management , Guidance250.00000
10207713204/01/2024 11:45:0012/01/2024 17:00:0004/01/2024 14:06:483.7Admin, Management, GuidancePerformancePassZonal0Admin , Management , Guidance250.00000
11207829804/01/2024 10:00:0012/01/2024 17:00:0018/01/2024 14:03:526.7Toilets,ShowersPerformanceFailZonal16Toilets , Showers10202.505062.590
12207832205/01/2024 14:39:0012/01/2024 17:00:0017/01/2024 18:24:413.7Admin, Management, GuidancePerformanceFailZonal14Admin , Management , Guidance25431.25125156.25150
13208121308/01/2024 12:44:0009/01/2024 10:44:0009/01/2024 09:24:503.5CirculationPerformancePassZonal0Circulation550.00000
14208206909/01/2024 09:03:0024/01/2024 16:00:0024/01/2024 10:41:293.2Admin, Management, GuidancePerformancePassZonal0Admin , Management , Guidance550.00000
15208207209/01/2024 09:05:0009/01/2024 13:05:0009/01/2024 10:06:439.2aCirculationPerformancePassZonal0Circulation350.00000
16208207909/01/2024 09:06:0024/01/2024 16:00:0018/01/2024 18:06:173.2Classrooms GeneralPerformancePassZonal0Classrooms- General550.00000
17208311709/01/2024 15:12:0010/01/2024 13:12:0009/01/2024 16:14:193.2Classrooms GeneralPerformancePassZonal0Classrooms- General550.00000
18208347709/01/2024 15:23:0010/01/2024 15:23:0009/01/2024 15:40:009.1Toilets,ShowersPerformancePassZonal0Toilets , Showers100.00000
19208358809/01/2024 15:39:0016/01/2024 15:39:0015/01/2024 18:32:463.7Classrooms PracticalPerformancePassZonal0Classrooms- Practical250.00000
20208410509/01/2024 15:00:0010/01/2024 09:00:0016/01/2024 13:20:007.1Other External AreasPerformanceFailWhole School12Other External Areas1001425.00500625300
21208411009/01/2024 15:30:0010/01/2024 09:30:0015/01/2024 16:30:007.1CirculationPerformanceFailWhole School10Circulation1001125.005006250
22208432310/01/2024 13:04:0017/01/2024 13:04:0016/01/2024 10:52:113.7Classrooms PracticalPerformancePassZonal0Classrooms- Practical250.00000
23208448210/01/2024 14:55:0011/01/2024 14:55:0013/01/2024 15:15:009.1Toilets,ShowersPerformanceFailZonal6Toilets , Showers1062.505012.50
24208559911/01/2024 14:09:0019/02/2024 15:00:00<no date entered>2.5CirculationPerformanceFailZonal0Circulation250.00000
25208607812/01/2024 08:27:0012/01/2024 16:27:0012/01/2024 08:40:003.5Admin, Management, GuidancePerformancePassZonal0Admin , Management , Guidance550.00000
26208770015/01/2024 09:33:0026/01/2024 16:00:0029/01/2024 15:30:002.6Dining, Kitchen, SportsPerformanceFailZonal22Dining , Kitchen , Sports25731.25125156.25450
27208771212/01/2024 10:30:0012/01/2024 12:30:0012/01/2024 11:15:001.1aPlaying fieldsPerformancePassWhole School0Playing Fields50.00000
28208787715/01/2024 10:35:0012/02/2024 16:00:00<no date entered>3.1Stores, plant, janitor etcPerformanceFailWhole School0Stores,plant,janitor etc.50.00000
29208791015/01/2024 10:50:0015/01/2024 14:50:0015/01/2024 10:58:339.2aClassrooms GeneralPerformancePassZonal0Classrooms- General350.00000
30208796615/01/2024 11:17:0015/01/2024 15:17:0015/01/2024 12:26:102.2aClassrooms PracticalPerformancePassWhole School0Classrooms- Practical550.00000
31208941916/01/2024 08:08:0016/01/2024 08:23:0016/01/2024 15:19:308.2Classrooms PracticalPerformanceFailZonal2Classrooms- Practical1020.002000
32208947616/01/2024 08:47:0023/01/2024 08:47:0018/01/2024 10:11:226.7CirculationPerformancePassZonal0Circulation100.00000
33208948016/01/2024 08:50:0016/01/2024 12:50:0016/01/2024 10:53:439.8Classrooms PracticalPerformancePassZonal0Classrooms- Practical450.00000
34208954916/01/2024 09:37:0017/01/2024 07:37:0016/01/2024 10:54:475.2Other External AreasPerformancePassZonal0Other External Areas200.00000
35208955716/01/2024 09:40:0016/01/2024 13:40:0016/01/2024 10:17:509.8CirculationPerformancePassZonal0Circulation450.00000
36208958115/01/2024 15:00:0016/01/2024 09:00:0015/01/2024 16:45:006.1Toilets,ShowersPerformancePassZonal0Toilets , Showers200.00000
37209066417/01/2024 08:56:0024/01/2024 08:56:0018/01/2024 18:07:556.7Classrooms PracticalPerformancePassZonal0Classrooms- Practical100.00000
38209072217/01/2024 08:51:0017/01/2024 11:51:0017/01/2024 12:28:543.4Classrooms GeneralPerformanceFailZonal2Classrooms- General55110.0011000
Sample data
Cell Formulas
RangeFormula
I5:I38I5=VLOOKUP($F5, Tbl_Specification[[Evo KPI]:[Performance/Availability]], 2, 0)
J5:J38J5=IF(E5<=D5,"Pass","Fail")
K5:K38K5=VLOOKUP($F5,Tbl_Specification[[Evo KPI]:[Zonal/Whole School]],3,0)
L5:L38L5=IF(E5="<no date entered>", 0, IF($J5="Pass",0,(NETWORKDAYS($C5,$E5,Tbl_Holidays[Date])*2)))
M5:M38M5=VLOOKUP($G5,Tbl_ZoneConcept[#Data],2,0)
N5:N38N5=VLOOKUP($F5, Tbl_Specification[[Evo KPI]:[Performance Points]], 6, 0)
O5:O38O5=SUM($P5:$R5)
P5:P38P5=IF($I5="Performance", IF($L5>=5, 5 *$N5, $L5*$N5), "")
Q5:Q38Q5=IF($I5="Performance", IF($L5<=5,0,IF($L5>=10,5*($N5*$Q$3),IF($L5<10,(($L5-5) *($N5*$Q$3)),0))),"")
R5:R38R5=IF($I5="Performance", IF($L5>10,(($L5-10)*($N5*$R$3)),0),"")
Named Ranges
NameRefers ToCells
EvoKPI=Tbl_Specification[Evo KPI]N5:N38, K5:K38, I5:I38
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hello KHaynes42 and welcome to the forum. It is difficult comparing dates in excel because the date displayed by the format it not usually the way that excel is storing the date information. For example excel stores the date in Cell D6 as 45299.5 and Cell E6 as 45299.4583333333.

One approach may be to add columns (even if you hide them later) that make the comparison much easier. You could add a column that just extracts the hour and that is all it displays and then compare it against the hour in another added column. You can do the same thing for days, months, years, minutes, seconds. Hope this makes sense and gets you started.

Extract for comparison
=Now()​
=Today()​
Extract MonthExtract Hour
=Month(C4)=hour(C4)
Wednesday, March 13, 2024​
3/13/24 11:53​
3/13/24​
311
Much easier to compare the extracted values.​
45364.50​
45364.00​
311
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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