+ Reply to Thread
Results 1 to 13 of 13

Subtract two times, exclude weekends

  1. #1
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Subtract two times, exclude weekends

    I am looking for a formula that subtracts two times from each other. I do not want Saturday and Sunday to be counted in the calculation.

    I was trying to use networkdays.intl but when the item arrived on saturday at a specific date and time and was done processing on Monday at a specific time and date the calculation showed over 24 hours where it should be under 24 hours. I would love for the formula to be in hours. Good Luck to whoever figures this out as it is not my first post on this.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-22-2014
    Location
    genoa, italy
    MS-Off Ver
    Excel 2007
    Posts
    134

    Re: Subtract two times, exclude weekends

    can this help ( http://www.mrexcel.com/forum/excel-q...-weekends.html ) ?

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,681

    Re: Subtract two times, exclude weekends

    My proposition:
    =NETWORKDAYS.INTL(MAX(A6,WORKDAY.INTL(A6-1,1,1)),B6,1)-MOD(MAX(A6,WORKDAY.INTL(A6-1,1,1)),1)+MOD(B6,1)

    And format for instance as [hh]:mm
    Please note that in last row you will get negative number, because as opposite to " I do not want Saturday and Sunday ..." the arrival is on Sat and processed on Sunday :-(

    Using NETWORKDAYS.INTL is a good idea because it allows to easily take into account holidays.

    if you want to have it as a number of hours take
    =(the formula_above)*24
    and use general format
    Attached Files Attached Files
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Subtract two times, exclude weekends

    AL1976 I think that worked out. Give me the week to play around with it and I will get back to you. All I had to do was add =networkdays.INTL

  5. #5
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Subtract two times, exclude weekends

    Kaper, you are actually the winner and spot on
    Last edited by blens1; 02-03-2014 at 12:19 PM.

  6. #6
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Subtract two times, exclude weekends

    Kaper, you are actually the winner and spot on. Do you know how to do incorporate holidays into that?

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,681

    Re: Subtract two times, exclude weekends

    both NETWORKDAYS.INTL and WORKDAY.INTL have the optional 4th argument - you can refer to list of holidays there. For instance if the list is in Z1:Z14 then

    =NETWORKDAYS.INTL(MAX(A6,WORKDAY.INTL(A6-1,1,1,$Z$1:$Z$14)),B6,1,$Z$1:$Z$14)-MOD(MAX(A6,WORKDAY.INTL(A6-1,1,1,$Z$1:$Z$14)),1)+MOD(B6,1)

    would do the job notice that WORKDAY is used twice so $Z$1:$Z$14 appeared 3 times above

  8. #8
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Subtract two times, exclude weekends

    Last but not least the formula is not working when the activity happens within the same day. So if you put in the appropriate cells that something arrived 2/3/14 11:16 and then unloaded 2/3/14 23:16 then it shows 1.50 but should be 0.50. This is the same for any activity within the same day. I definitely appreciate your help Kaper!!!!

  9. #9
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,681

    Re: Subtract two times, exclude weekends

    May be you shall subtract 1 at the and. Check this out.
    Today start and today end means 1 day activity for NETWORKDAYS . Today start (evening) and tomorrow end (morning) means 2 day activity. The NETWORKDAYS cares for days only

  10. #10
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Subtract two times, exclude weekends

    I understand. I can't subtract 1 though because then it would subtract 1 for every other instance where the process involves more then 1 day.

  11. #11
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,681

    Re: Subtract two times, exclude weekends

    Have you tried:
    =NETWORKDAYS.INTL(MAX(A6,WORKDAY.INTL(A6-1,1,1,$Z$1:$Z$14)),B6,1,$Z$1:$Z$14)-MOD(MAX(A6,WORKDAY.INTL(A6-1,1,1,$Z$1:$Z$14)),1)+MOD(B6,1)-1
    Try !

  12. #12
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,681

    Re: Subtract two times, exclude weekends

    I say: Have you really tried?
    I did.
    See attachment.
    Attached Files Attached Files

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Subtract two times, exclude weekends

    That works for me, Kaper, but you can simplify a little with this version

    =NETWORKDAYS(A6,B6,Z$1:Z$14)-1+MOD(B6,1)-NETWORKDAYS(A6,A6,Z$1:Z$14)*MOD(A6,1)

    Assumes that A6 is any time but B6 will be within work hours - multiply by 24 if you want decimal hours otherwise format as [h]:mm
    Audere est facere

+ 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. hour difference between two dates/times, exclude weekends and holidays
    By lamdl in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-23-2014, 09:11 PM
  2. Replies: 5
    Last Post: 05-18-2012, 10:24 AM
  3. [SOLVED] subtract a delivery date:Date Calculation to exclude weekends
    By Vim in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-24-2006, 11:00 AM
  4. calculation to exclude weekends
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-06-2005, 04:05 AM
  5. calculation to exclude weekends
    By Need2Know in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-14-2005, 04:05 PM

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