Compare Multiple Dates - Recalculate based on Start and End Dates

jrball

New Member
Joined
Feb 9, 2023
Messages
2
Office Version
  1. 365
My XL2BB code below is to attempt to recalculate attendees join and leave times that were recorded and use the Session Start Date and Times to measure and calculate the total duration of the time spent in the session per attendee per line.

The calculations are correctly working in column F where I am updated a recalculated join time based on the start date and time. For example, if join time is before 6:00, the recalculated join time in F gets set to the start time of 6:00, and if I join after 6:00 it's set to the time I joined.

Question #1 - I haven't accounted for an attendee joining after the End Date and Time, but I think I will have to, and not sure how to solve. (Maybe it's similar to the question #2 below on Leave Time.)

I am struggling with how to address the column G fields to properly recalculate the correct date and time based on the B2 Start Date and Time, and the B3 End Date and Time.

The calculated leave time column is where I am having some problems due to the leave time being prior to both the start and end times. The row 9 entry for attendee 2 joined and left before the start time, so they shouldn't get 12s of duration, but should get 0s of duration.

Question #2 - How to solve for cancelling out calculated join time and leave time to show if Join Time (C) AND Leave Time (D) is prior to Start Date and Time (B2) then the Calculated Leave Time (G) should be = B2

So the output for the Line 9 would be for the Columns F and G both equal to 2/1/2023 6:00 and then the calculated duration would = 0

The exception would be if the Calculated Leave time for other values in that column would be recalculated to the Session End date of 2/1/2023 7:30 if the attendee's leave time from column D is later than the session end date and time.

I can get one or the other to work for question #2 and can't figure out how to make both scenarios work in one formula.

Attend.xlsx
ABCDEFGH
1
2Start Date and Time2/1/2023 6:00
3End Date and Time2/1/2023 7:30
4
5
6Join timeLeave timeDurationCalculated Join TimeCalculated Leave TimeCalculated Duration
7Attendee 12/1/2023 6:00:562/1/2023 6:53:3252m 35s2/1/2023 6:00:562/1/2023 6:53:320:52:36
8Attendee 12/1/2023 7:10:452/1/2023 7:30:1719m 32s2/1/2023 7:10:452/1/2023 7:30:000:19:15
9Attendee 22/1/2023 5:58:202/1/2023 5:58:3212s2/1/2023 6:00:002/1/2023 5:58:32#################
10Attendee 22/1/2023 6:00:082/1/2023 6:53:4253m 34s2/1/2023 6:00:082/1/2023 6:53:420:53:34
11Attendee 22/1/2023 7:10:442/1/2023 7:30:3719m 53s2/1/2023 7:10:442/1/2023 7:30:000:19:16
12Attendee 32/1/2023 6:00:322/1/2023 6:53:4253m 10s2/1/2023 6:00:322/1/2023 6:53:420:53:10
13Attendee 32/1/2023 7:10:442/1/2023 7:30:0819m 23s2/1/2023 7:10:442/1/2023 7:30:000:19:16
14Attendee 42/1/2023 5:56:262/1/2023 6:53:4357m 17s2/1/2023 6:00:002/1/2023 6:53:430:53:43
15Attendee 42/1/2023 7:11:202/1/2023 7:28:2717m 6s2/1/2023 7:11:202/1/2023 7:28:270:17:07
Sheet1
Cell Formulas
RangeFormula
F7:F15F7=IF(C7<=$B$2,$B$2,C7)
G7:G15G7=IF(D7>=$B$3,$B$3,D7)
H7:H15H7=G7-F7
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
See if this works for you. Put it in G7 and copy down:
Excel Formula:
=IF(D7<F7,F7,IF(D7>=$B$3,$B$3,D7))
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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