+ Reply to Thread
Results 1 to 7 of 7

Overlap of date and time

  1. #1
    Registered User
    Join Date
    06-24-2022
    Location
    Detroit, Michigan
    MS-Off Ver
    365
    Posts
    4

    Overlap of date and time

    Hello,

    Excel help please! I'm trying to calculate the total time someone was in attendance, the report I have shows overlapping dates/times. I need to calculate the overall time in attendance down to the minute. Below is a sample of what I am working from, this is a multiple day event so I would need total time for all days combined.

    Thank you!

    Day Email Start Time Leave Time Email Total Time
    Day 1 Snowwhite111 6/8/2022 8:57 6/8/2022 10:39 Snowwhite111
    Day 1 Snowwhite111 6/8/2022 8:02 6/8/2022 8:51 Sleepyabc
    Day 1 Snowwhite111 6/8/2022 8:52 6/8/2022 8:57 Docnyc
    Day 2 Snowwhite111 6/9/2022 8:57 6/9/2022 10:39 Grumpy367
    Day 1 Grumpy367 6/8/2022 8:51 6/8/2022 10:39
    Day 1 Grumpy367 6/8/2022 8:02 6/8/2022 8:51
    Day 2 Grumpy367 6/9/2022 8:02 6/9/2022 9:51
    Day 1 Docnyc 6/8/2022 8:02 6/8/2022 10:39
    Day 1 Docnyc 6/8/2022 8:05 6/8/2022 10:04
    Day 1 Docnyc 6/8/2022 10:04 6/8/2022 10:39
    Day 2 Docnyc 6/9/2022 8:04 6/9/2022 10:39
    Day 1 Sleepyabc - -
    Day 2 Sleepyabc - -

    Edit - added attachment.
    Attached Files Attached Files
    Last edited by estes2; 06-24-2022 at 11:30 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Overlap of date and time

    Welcome to the forum.

    Your workbook should include some manually calculated results to show us what you want, so this is a guess:

    =SUMPRODUCT(($B$2:$B$14=H2)*($D$2:$D$14-$C$2:$C$14))

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    H
    I
    2
    Snowwhite111
    04:17:32
    3
    Sleepyabc
    00:00:00
    4
    Docnyc
    07:46:52
    5
    Grumpy367
    04:25:27
    Sheet: Details
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    06-24-2022
    Location
    Detroit, Michigan
    MS-Off Ver
    365
    Posts
    4

    Re: Overlap of date and time

    Thank you AliGW, unfortunately this doesn't work, the formula that you provided is counting the overlap in time. Example, Docnyc started at 8:02 and ended at 10:39, but he also has access from another device showing time 8:05 - 10:04 and 10:04 - 10:30. Since the two entries on one day overlap time already provided on that day they can't count, only time that does not overlap can be counted such as Snowwhite111. I would need total time no matter how many devices they logged into on.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Overlap of date and time

    This is why you should add expected results and explanatory notes to your sample workbook. Can you do this now, please?

  5. #5
    Registered User
    Join Date
    06-24-2022
    Location
    Detroit, Michigan
    MS-Off Ver
    365
    Posts
    4

    Re: Overlap of date and time

    Thank you, I hope the attached is what you are looking for.
    Attached Files Attached Files
    Last edited by estes2; 06-24-2022 at 01:50 PM. Reason: adding attachment

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Overlap of date and time

    Here's how I did it. I hope I can explain it so it makes sense:

    1) You didn't offer an algorithm, so I made one up. The basic idea is that, if I have the time stamps sorted in ascending order and I know which are start and which are leave, then I can start at the "top" and turn "accumulation" on at the right start times and turn "accumulation" off at the right leave times.
    2) First step is to unpivot the existing table, then sort by name first, then date/time stamp, and then start or leave (columns M, N, O in attached).
    3) Since I need to be able to see pairs of rows, I add a helper column in column P that pairs rows up. The formula here is =IF(M3=M2,O2,"")&O3. This column can take on 5 possible values:
    s -- means start of a new person/email. start remembering earliest start time of the first set.
    ss -- means two start times in a row. When there are multiple start times in a row, we need to remember the earliest start time of the set.
    sl -- change from start to leave time. start remembering leave times until the end of this leave set.
    ll -- means two leave times in a row. When there are multiple leave times in a row, we need to accumulate until the last leave time of the set.
    ls -- change from leave to start. start remembering earliest start time of this start set.
    4) Column Q will be a series of nested IF() functions to execute the logic described above. =IF(P3="s",N3,IF(P3="ss",Q2,IF(P3="sl",Q2+N3,IF(P3="ll",Q2+N3-N2,IF(P3="ls",Q2-N3,NA()))))). The basic arithmetic is to sum up the appropriate leave times and then subtract the sum of the appropriate start times. Note that I chose to format as general rather than time here because Excel (unlike other spreadsheets) does not like to display negative times. General formatting doesn't have trouble showing positive or negative values here.
    5) The total time online for each person is the last entry associated with their name. A simple lookup function (I used VLOOKUP()) can be used to extract the desired value.

    Is that useful?
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Registered User
    Join Date
    06-24-2022
    Location
    Detroit, Michigan
    MS-Off Ver
    365
    Posts
    4

    Re: Overlap of date and time

    Thank you MrShorty. I actually just figured out a solution. I found a string in another spreadsheet and played with it until I got it to work. Here is my end result: =IF(A3<>"",NUMBERVALUE(TEXT((MAXIFS('Usage Report'!$M$16:$M$623,'Usage Report'!$C$16:$C$623,A3,'Usage Report'!$A$16:$A$623,"Day 1")-MINIFS('Usage Report'!$L$16:$L$623,'Usage Report'!$C$16:$C$623,'Reconciliation Report'!A3,'Usage Report'!$A$16:$A$623,"Day 1"))*1440+(MAXIFS('Usage Report'!$M$16:$M$623,'Usage Report'!$C$16:$C$623,A3,'Usage Report'!$A$16:$A$623,"Day 2")-MINIFS('Usage Report'!$L$16:$L$623,'Usage Report'!$C$16:$C$623,'Reconciliation Report'!A3,'Usage Report'!$A$16:$A$623,"Day 2"))*1440,"0.00")),0)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Overlap between date and time in excel
    By kukku in forum Excel General
    Replies: 9
    Last Post: 05-28-2019, 12:04 AM
  2. Comparing Date and Time overlap by employee
    By mike182 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-22-2018, 08:55 PM
  3. [SOLVED] Overlap for Date/Time
    By Brawnystaff in forum Excel General
    Replies: 2
    Last Post: 06-19-2015, 10:35 PM
  4. [SOLVED] determine total overlap time when there are gaps in overlap (4 date ranges)
    By miriambender in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-12-2014, 11:58 PM
  5. Date + time overlap checking
    By zRc55 in forum Excel General
    Replies: 21
    Last Post: 09-27-2013, 01:34 AM
  6. [SOLVED] Check for date and time overlap on a simple invoice
    By DJadwin in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-19-2013, 10:11 PM
  7. Calculating date/time overlap for multiple equipment
    By rhojjati in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-03-2012, 11:33 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1