+ Reply to Thread
Results 1 to 4 of 4

Calculating work hours between two datetimes

  1. #1
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Calculating work hours between two datetimes

    Hi!

    I have datetimes in ranges I2# and J2#. I need to sum work time within the duration of these datetimes with a formula that creates a spill range.

    The shift patterns are described in the table called �Tab_shift_pattern� with the following columns:

    �Day of week� = the days of the week in text that cycles through Monday to Sunday repeatedly. The seven rows 2 to 8 (seven rows) are set aside for a certain period where a factory works according to a specific shift pattern that is described in the table on these rows. Then, at a later time, the shift pattern may change, and so the next seven rows (9 to 15) contain the setup for this period. And so on. There are therefore several blocks of seven days beneath each other in this column.

    �Start date of shift pattern� = This column gives the first date that a certain shift pattern was implemented. So for the first seven rows, this column will contain the same date in each of the rows. Then, for the next seven rows, the start date of the next shift pattern will be there for all of those seven rows. Etc. depending on how many seven-row blocks we have.

    �End date of shift pattern� = This column gives the last date that a certain shift pattern was being followed. So for the first seven rows, this column will contain that same date in each of the rows. Then, for the next seven rows, the end date of the next shift pattern will be there for all of those seven rows. Etc. depending on how many seven-row blocks we have. Thus, the start and end date where a certain shift pattern is valid will be entered outside each of the days of the week from Monday to Sunday. Then, a new block of seven days comes with a new period and so forth.

    �Weekday� = this column contains numbers from 1 to 7 indicating the day of week, similar to what we have in text form in �Day of week�.

    �Work time start� = this column contains the start time of day when a shift start for a particular weekday. So for each of the seven rows in the block for a certain shift pattern there may be different times for �Work time start� depending on which weekday it is.

    �Work time end� = this column contains the end time of day when a shift ends for a particular weekday. So for each of the seven rows in the block for a certain shift pattern there may be different times for �Work time end� depending on which weekday it is.

    I have uploaded an Excel workbook that shows the data. Note: The start datetimes of I2# may fall within a different shift pattern block than the end datetimes J2#, but will most of the time be in the same shift pattern block.

    Any help is appreciated!

    Best regards,
    Marbleking
    Attached Files Attached Files
    Last edited by Marbleking; 01-14-2024 at 05:35 PM.

  2. #2
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: Calculating work hours between two datetimes

    One way:

    Please try in K2 and copy down:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Calculating work hours between two datetimes

    Thanks a lot, Hans! I tried to have ChatGPT turn your formula into a spill range version, but I wasn't able to get it completely right. You can see the results in the updated workbook. Perhaps you're able to see what's wrong?

    Best regards,
    Marbleking
    Attached Files Attached Files

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: Calculating work hours between two datetimes

    Please try:
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. Replies: 3
    Last Post: 09-03-2023, 05:12 AM
  2. [SOLVED] Calculate difference between 2 datetimes in hours excluding Weekends and Holidays.
    By Akcena007 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 02-24-2023, 09:49 PM
  3. [SOLVED] Calculate differnece between 2 datetimes in hours excluding Weekends and Holiday Hours.
    By Akcena007 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-06-2023, 09:53 AM
  4. [SOLVED] Convert text dates and datetimes to formatted number datetimes
    By Marbleking in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-18-2021, 11:02 AM
  5. [SOLVED] Overtime hours between two datetimes relative to custom weekly schedule
    By Marbleking in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-27-2021, 06:08 AM
  6. Replies: 7
    Last Post: 07-25-2012, 09:14 AM
  7. Replies: 1
    Last Post: 11-29-2011, 12:19 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