+ Reply to Thread
Results 1 to 10 of 10

Thread: Time between timestamps excluding certain hours

  1. #1
    Registered User
    Join Date
    09-01-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Time between timestamps excluding certain hours

    Hi. I know this subject has been touched upon a lot in here, but i have failed to make it work for me

    Basically, i have two timestamps, I want to find out how many business hours there is between them, so i would be excluding hours between 06:00 and 18:00 from timestamps such as: 08-05-2011 15:32:27 and 09-05-2011 10:10:54 not counting the 12 hours between 6PM and 6AM, but still taking into account that two timestamps can be from the same day but differet times (so just subtracting 12 hours wont work)..

    Anyone can point me in the right direction ?

  2. #2
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127

    Re: Time between timestamps excluding certain hours

    If first stamp in A1 and second in B1,
    maybe
    =IF(INT(A1)=INT(B1),B1-A1,MOD(B1-A1,1)-0,5)
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

  3. #3
    Registered User
    Join Date
    09-01-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Time between timestamps excluding certain hours

    Brilliant, it worked..

    Thanks a million :-)

    If you have time, could you explain the formula to me ? or point me to where I can read about the functions you use ?

    If you have the time..

  4. #4
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127

    Re: Time between timestamps excluding certain hours

    If nobody else has done it, I'll give it a go tomorrow if you don't mind
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

  5. #5
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057

    Re: Time between timestamps excluding certain hours

    Are business hours 6-18 on all days, even Saturday and Sunday? Are the timestamps always within the business hours (or could your start time be 4AM for instance....or the end time be 8PM)?
    Audere est facere

  6. #6
    Registered User
    Join Date
    09-01-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Time between timestamps excluding certain hours

    Hmm might have been too quick there, it works with the hours but not with the days :-/

    As is, It works if one day is, say, 30-08-2011 13:30 and second 31-08-2011 09:00 it counts 7:30 hours which is great, but if i change the first date to 29-08-2011 13:30 it still only counts 7:30 .. I need it to also count the full work hours of the day in between..

    Any ideas ??

  7. #7
    Registered User
    Join Date
    09-01-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Time between timestamps excluding certain hours

    @Daddylonglegs

    Timestamps are always within business hours, Sat and Sun is not business hours

  8. #8
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057

    Re: Time between timestamps excluding certain hours

    Try this version

    =(NETWORKDAYS(A1,B1)-1)/2+MOD(B1,1)-MOD(A1,1)

    custom format result cell as [h]:mm

    note the square brackets.....

    NETWORKDAYS function is part of Analysis ToolPak add-in in Excel 2003 - if formula doesn't work then activate the add-in

    Tools > add-ins > tick "Analysis ToolPak" box
    Audere est facere

  9. #9
    Registered User
    Join Date
    09-01-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Time between timestamps excluding certain hours

    The NETWORKDAYS worked like a charm, thanks :-)..

    One question though:
    In the odd event the business hours change, which part of the formula should i look at ?

  10. #10
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057

    Re: Time between timestamps excluding certain hours

    Because your hours are half of the day I divided by 2 but this more generic version includes the times....

    =(NETWORKDAYS(A1,B1)-1)*("18:00"-"06:00")+MOD(B1,1)-MOD(A1,1)
    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)

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.2.0