+ Reply to Thread
Results 1 to 7 of 7

Hours difference between 2 Date & Time stamps

  1. #1
    Registered User
    Join Date
    09-14-2007
    Posts
    7

    Smile Hours difference between 2 Date & Time stamps

    Hi trying to set up a a formula based around the following:

    A1 B2
    01/01/07 14:00 10/01/07 16:00

    finding out the hours between the 2 date time stamps in each cell based on a 10 hour working day also excluding the weekends. I have found the below formula but it brings up incorrect hours on some date time calculations
    Any Help would be appreciated.
    =NETWORKDAYS(E2,H2)-1-MOD(E2,1)+MOD(H2,1)

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736
    You need to include the 10 hour day in there, i.e.

    =(NETWORKDAYS(E2,H2)-1)*"10:00"-MOD(E2,1)+MOD(H2,1)

    format as [h]:mm

    E2 and H2 should both be within working hours

  3. #3
    Registered User
    Join Date
    09-14-2007
    Posts
    7
    Thanks for the input, one issue is now there it comes up with a error in the formula based on the -1

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736
    I don't get an error, are you using exactly the formula above?

    You may get a strange result if either E2 or H2 are blank, which you can avoid by changing to

    =IF(AND(E2<>"",H2<>""),(NETWORKDAYS(E2,H2)-1)*"10:00"-MOD(E2,1)+MOD(H2,1),"")

  5. #5
    Registered User
    Join Date
    09-14-2007
    Posts
    7
    Hi Daddylonglegs,

    Thanks for your help on this, your formula is working fine in some cells and others it is giving the incorrect answer, not sure why. I have attached the excel sheet Im working on as a text file.

    Again your helps is appreciated.
    Attached Files Attached Files

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736
    I can see the results of the formula but not the formula itself. It doesn't look like you're using the formula I suggested because the results are different from those I get using that formula, i.e. in I2 the formula

    =(NETWORKDAYS(E2,H2)-1)*"10:00"-MOD(E2,1)+MOD(H2,1)

    formatted as [h]:mm gives me the result of 50:00 yet your sheet shows 60:00. Also some of the dates are Sundays. The formula above isn't designed for situations where your start or end dates/times are outside your 10 hour Monday to Friday workday. If you need to consider this possibility then you need a different formula......

  7. #7
    Registered User
    Join Date
    09-14-2007
    Posts
    7

    Smile

    Hey Daddylonglegs, thanks for your help its working a treat.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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