+ Reply to Thread
Results 1 to 8 of 8

Need formula to calculate time in hours between two date ranges

Hybrid View

annyfouanny Need formula to calculate... 06-27-2011, 03:35 AM
royUK Re: Need formula to calculate... 06-27-2011, 04:11 AM
Roger Govier Re: Need formula to calculate... 06-27-2011, 04:40 AM
annyfouanny Re: Need formula to calculate... 06-27-2011, 04:46 AM
Roger Govier Re: Need formula to calculate... 06-27-2011, 04:53 AM
annyfouanny Re: Need formula to calculate... 06-27-2011, 06:19 AM
annyfouanny Re: Need formula to calculate... 06-27-2011, 04:41 AM
nawas Re: Need formula to calculate... 06-27-2011, 05:01 AM
  1. #1
    Registered User
    Join Date
    04-29-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    12

    Thumbs up Need formula to calculate time in hours between two date ranges

    Hi,

    I need a formula to calculate the time in hours/minutes for the below situation.

    I have A1, B1 cells with open and closed dates with time stamp. Now i need the difference between two dates in hours/minutes with criteria 1) only workdays should be calculated 2) only hours/minutes should be calculated between 10am to 8pm.

    I need the output like below

    Opened Closed Time taken in hours
    3/3/11 8:39 3/3/11 18:30 6.3
    3/1/11 14:30 3/2/11 19:00 12.3

    Please help me.
    Attached Files Attached Files
    Last edited by annyfouanny; 06-27-2011 at 06:26 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Need formula to calculate time in hours between two date ranges

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Need formula to calculate time in hours between two date ranges

    Hi

    Does the attached workbook do what you want?

    I don't make the results the same as you show however, as the first line results in 8:30 hours and the second 18:30 hours
    Attached Files Attached Files
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  4. #4
    Registered User
    Join Date
    04-29-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Need formula to calculate time in hours between two date ranges

    Quote Originally Posted by Roger Govier View Post
    Hi

    Does the attached workbook do what you want?

    I don't make the results the same as you show however, as the first line results in 8:30 hours and the second 18:30 hours
    Hi Roger,

    Thank you for your response. How ever I dint get the anticipated result. I have added sample workbook that what i am looking for. Can please have a look and help me.

    Thank you!!!
    Anil.

  5. #5
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Need formula to calculate time in hours between two date ranges

    Quote Originally Posted by annyfouanny View Post
    Hi Roger,

    Thank you for your response. How ever I dint get the anticipated result. I have added sample workbook that what i am looking for. Can please have a look and help me.

    Thank you!!!
    Anil.
    Hi Anil

    I have changed the entries on my workbook to match yours, and I still believe that your calculation is incorrect.

    take example 1
    The only effective time is from 10:00 to 18:30 which is 8:30 hours

    In example 2
    On day 1 the time is from 14:30 to 20:00 which is 5:30 hours
    On day 2 it is from 10:00 to 19:00 which is 9:00 hours
    giving a total of 14:30 hours
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-29-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Need formula to calculate time in hours between two date ranges

    Quote Originally Posted by Roger Govier View Post
    Hi Anil

    I have changed the entries on my workbook to match yours, and I still believe that your calculation is incorrect.

    take example 1
    The only effective time is from 10:00 to 18:30 which is 8:30 hours

    In example 2
    On day 1 the time is from 14:30 to 20:00 which is 5:30 hours
    On day 2 it is from 10:00 to 19:00 which is 9:00 hours
    giving a total of 14:30 hours
    Hi Roger,

    Yes you are correct, now its working for me.. thank you much...

  7. #7
    Registered User
    Join Date
    04-29-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Need formula to calculate time in hours between two date ranges

    Hi royUK,

    Thank you for your response. I have attached a sample workbook to my post. Please help me ASAP.

  8. #8
    Forum Contributor
    Join Date
    05-04-2009
    Location
    ME
    MS-Off Ver
    Excel 2003,2007
    Posts
    157

    Re: Need formula to calculate time in hours between two date ranges

    Check this as well...

    =IF(((B1-A1)<0),"",MIN(MOD(B1,1),D1)-MAX(MOD(A1,1),C1)+(SUM(IF(WEEKDAY(INT(A1)-1+ROW(INDIRECT("1:"&(INT(B1)-INT(A1))+1)))=TRANSPOSE({2,3,4,5}),1,0))-1)*(D1-C1))

    Where
    a1 is opened
    b1 is closed
    c1 is start time (10:00)
    d1 is close time (20:00)

    Thanks

+ 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