+ Reply to Thread
Results 1 to 15 of 15

Calculating age of open cases

  1. #1
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Calculating age of open cases

    Hi everyone

    I've spent some time looking through previous threads and found some help, but can't quite get what I need.

    I am just trying to look at the age of open cases in a report. I want to know in hours (and maybe minutes) not including weekends. I have the created date and time in J2 and "Now" date and time in K2.

    I've used the following that I got from another thread: =NETWORKDAYS(J2,K2-1+MOD(K2,1)-MOD(J2,1))

    But it seems to be only giving me hours in 24 hour increments. For example a case raised on 22/5/09 gives a time of 72.00 this morning.

    I'd be really grateful of some pointers

    Slongy
    Last edited by Slongy; 06-05-2009 at 03:50 AM.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Calculating age of open cases

    Do you want to know differ. in in hours/minutes between two days?
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Calculating age of open cases

    Hi, yes, between the created date and time in J2 and the current date and time in K2

    Slongy

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Calculating age of open cases

    U mean smth like this??
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculating age of open cases

    Richard Schollar wrote the following article some time back. I think it will clearly explain the solution:

    Requirement:
    Calculate the time between two date/time values (eg 22/1/2008 14:32) where you only want to return the cumulative time between the hours of 8am and 8pm (can be adjusted for any time period interested in eg 9am to 5:30pm for a working day, perhaps).

    Given:
    A1 ---- Start Date/Time ---- 21/1/2008 06:30
    B1 ---- End Date/Time ---- 22/1/2008 09:45

    Time span of interest:
    Time between 8am and 6pm

    Generalized Formula:
    =(INT(B1)-INT(A1))*(HoursDayEnd-HoursDayStart)/24+MEDIAN(0,(HoursDayEnd-HoursDayStart)/24,MOD(B1,1)-HoursDayStart/24)-MEDIAN(0,MOD(A1,1)-HoursDayStart/24,(HoursDayEnd-HoursDayStart)/24)

    Where:
    HoursDayStart = 8 ---- (8am start)
    HoursDayEnd = 18 ---- (6pm finish, 24 hour clock)
    Note if fractions of hours required eg 8:30am start, 6:45pm finish, then you would replace HoursDayStart with 8.5 (30 minutes is 0.5 of an hour) and HoursDayEnd with 18.75 respectively.

    This results in the specific formula:
    =(INT(B1)-INT(A1))*(18-8)/24+MEDIAN(0,(18-8)/24,MOD(B1,1)-8/24)-MEDIAN(0,MOD(A1,1)-8/24,(18-8)/24)

    Which returns 11:45 (remember to format the formula cell as [h]:mm to display an aggregate time and not a date value) - 10 hours on the 21st plus 1 hour 45 mins on the 22nd.

    This will work with any date/time combination as long as the date/time in A1 is before the date/time in B1. Note that weekends are not excluded by this formula.

    To exclude weekends:

    =(NETWORKDAYS(A1,B1)-1)*(HoursDayEnd-HoursDayStart)/24+MEDIAN(0,(HoursDayEnd-HoursDayStart)/24,MOD(B1,1)-HoursDayStart/24)*(WEEKDAY(B1,2)<6)-MEDIAN(0,MOD(A1,1)-HoursDayStart/24,(HoursDayEnd-HoursDayStart)/24)*(WEEKDAY(A1,2)<6)

    Note that this requires the installation of the Analysis Toolpak Add-In in Excel versions prior to Excel 2007.

    The following works without the Analysis Toolpak:

    =(SUM(INT((WEEKDAY(A1-{2,3,4,5,6})-INT(A1)+INT(B1))/7))-1)*(HoursDayEnd-HoursDayStart)/24+MEDIAN(0,(HoursDayEnd-HoursDayStart)/24,MOD(B1,1)-HoursDayStart/24)*(WEEKDAY(B1,2)<6)-MEDIAN(0,MOD(A1,1)-HoursDayStart/24,(HoursDayEnd-HoursDayStart)/24)*(WEEKDAY(A1,2)<6)
    Regards

    Jon (Excel 2003, 2007, 2010, 2013)

  6. #6
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Calculating age of open cases

    Yes, kind of. Except I want minutes as well, this is how the fields are set up:

    Created date Current Date
    2009-05-12 0:00:00 27/05/2009 10:14

    So I'm getting a result of 264 which seems to be the complete days (11 days) but doesn't show me the inclomplete days. Every result is a multiple of 24. Maybe it's to do with the formatting of the date and time fields??

  7. #7
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Calculating age of open cases

    Hang on, I'll take a look at Jon's reply. Thanks

  8. #8
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Calculating age of open cases

    Thanks for the reply Jon. I've tried the version that should exclude weekends but I'm not getting a result. It's probably over complicated anyway as it has elements to look at specific ranges of hours which I don't need.. I'm still stuck

  9. #9
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculating age of open cases

    I'll have a look if you post a sample...

  10. #10
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Calculating age of open cases

    Here's an example (attached)

    Case opened at 9am on 26th, current time 10am on 27th. This should be 25 hours but I'm always getting 24

    Slongy
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculating age of open cases

    I mean a sample that illustrates your ranges of hours not needed.

  12. #12
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Calculating age of open cases

    For now, I'm happy just excluding the weekends so using the Networkday function is fine.

    I'm not trying to restrict to office hours or anything, just Monday to Friday 0.00 - 23.59

  13. #13
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculating age of open cases

    How about:

    =(((B2-A2)*24)-(INT((B2-A2)-NETWORKDAYS(A2,B2-1))*24))/24

    formatted as [h]:mm
    Last edited by JONvdHeyden; 05-27-2009 at 07:36 AM.

  14. #14
    Registered User
    Join Date
    05-22-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Calculating age of open cases

    Thanks Jon, I think that's it!

    Fantastic, I really appreciate the help

  15. #15
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculating age of open cases

    Great! Can you mark this post as solved then please.

+ 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