+ Reply to Thread
Results 1 to 6 of 6

Correct format to display business hours/days

  1. #1
    Registered User
    Join Date
    09-22-2015
    Location
    atl, ga
    MS-Off Ver
    2013
    Posts
    4

    Correct format to display business hours/days

    Hi. I've been wracking my brain for days trying to get the correct format to display in my table. I've (hopefully) successfully calculated time between two dates, excluding weekends, holidays, and outside of business hours (see below for full formula).

    What I'm stuck on is the FORMAT of the data. I need the cell to display "##d ##h ##m". I've come up with "dd\d hh\h mm\m". The cell now displays correctly, but the data is wrong. Please help with either my formula to calculate the time span, or the format of the cell, please.

    Formula to calculate time span : =(NETWORKDAYS(A2,B2,Holidays!A:A)-1)*("20:00"-"08:00")+IF(NETWORKDAYS(B2,B2,Holidays!A:A),MEDIAN(MOD(B2,1),"20:00","08:00"),"20:00")-MEDIAN(NETWORKDAYS(A2,A2,Holidays!A:A)*MOD(A2,1),"20:00","08:00")

    Business hours are 8am to 8pm

    Format of the cells : d\d hh\h mm\m

    A1
    09/10/2015 12:51 AM
    03/27/2015 4:15 PM
    03/20/2014 9:00 AM

    B1
    09/14/2015 10:55 AM
    09/16/2015 11:59 PM
    09/16/2015 11:59 PM

    Unformatted Results
    1.121527778
    60.15625
    188.4583333

    Formatted
    1d 02h 55m
    29d 03h 45m
    6d 11h 00m

    Should look like
    2d 2h 55m
    120d 3h 44m
    376d 11h 0m

    "Raw" time
    26 hours 55 minutes
    1443 hours 44 minutes
    4523 hours 0 minutes

    I need the result in BUSINESS DAYS and HOURS, please
    Last edited by M.e.R.; 09-22-2015 at 01:23 PM. Reason: Table displayed wonky

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Correct format to display business hours/days

    Hi, welcome top the forum

    If you are working with time, and are using "20:00" then that is probably text, not a number/time.

    What you need to understand about dates and times in excel is...

    a date is just a number representing the number of days passed since 1/1/900...and then formated in a way that we recognise as a date. So, for instance, today (Tue Sep 2015) is actually 42269

    Time is actually a decimal part of 1 (day), so 06:00 AM is 0.25, 12 noon is 0.5 and 18:00 (or 6 PM) is 0.75

    To run calcs like that, I often just use 8/24 or 20/24
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    09-22-2015
    Location
    atl, ga
    MS-Off Ver
    2013
    Posts
    4

    Re: Correct format to display business hours/days

    Thanks for the feedback, FDibbins! I just tweaked my table to include new columns C - 8:00 AM and D - 8:00 PM. I then tweaked the formula (removed 20:00 and 8:00). Sadly, nothing changed. My results are still incorrect (there are 1/2 the number of days that should be).

    I appreciate the assistance!! Anything else you can think of, please?

  4. #4
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Correct format to display business hours/days

    Hi,

    Can you please post a sample template of your excel file here? Use the following URL for help on how to upload a file.

    http://www.excelforum.com/members/da...ch-a-file.html

  5. #5
    Registered User
    Join Date
    09-22-2015
    Location
    atl, ga
    MS-Off Ver
    2013
    Posts
    4

    Re: Correct format to display business hours/days

    Here are both the original and tweaked tables. I took FDibbins feedback and make a couple of tweaks, and those are reflected in the Time Span - tweaked file.

    Time Span - Tweaked.xlsx
    Time Span.xlsx

    Thanks :-)

  6. #6
    Registered User
    Join Date
    09-22-2015
    Location
    atl, ga
    MS-Off Ver
    2013
    Posts
    4

    Re: Correct format to display business hours/days

    I've got it!!

    The original formula was correct. I had to create a new column and have it concatenate and multiply for me... Here's the final result:

    =CONCATENATE(INT(C2)*2,"d ",INT(MOD(C2,1)*24),"h ",INT(MOD(MOD(C2,1)*24,1)*60),"m")

+ 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. Converting Total Hours to Business Hours/Days
    By Fadooshy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-27-2015, 12:26 PM
  2. Networkdays Calculate non business days/hours
    By EH003268 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-16-2015, 10:56 AM
  3. Replies: 2
    Last Post: 11-12-2014, 11:56 AM
  4. Removing non business days & hours
    By Shakey in forum Excel General
    Replies: 6
    Last Post: 01-06-2014, 02:55 AM
  5. Removing non business days & hours & lunch break
    By Tom Hill in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-15-2013, 03:43 AM
  6. How to solve working hours/business days query
    By Gaz863 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-21-2011, 08:59 AM
  7. Replies: 0
    Last Post: 04-07-2011, 01:46 AM

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.6.0 RC 1