+ Reply to Thread
Results 1 to 7 of 7

Calculate difference between dates and times - display as percent elapsed

  1. #1
    Registered User
    Join Date
    02-20-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    7

    Question Calculate difference between dates and times - display as percent elapsed

    I have a sheet with start and end dates and times, like this: 02/20/2018 12:00. These days and times span many days. I currently have it calculating the difference between these dates and times, and displaying that time as “Duration” in Days / Hours. I would like it to calculate half hour increments. (My start and end times will always be hours or half hours)

    My formula is this:
    HTML Code:
    Please Login or Register  to view this content.
    It displays 3 Days 2 Hours, but I would like it to show 3 Days 2.5hours, as the INT is rounding down the hours.

    I would also like to be able to calculate the percentage time elapsed between the start date / time, and the current date / time.

    Thanks in advance for the assistance!

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Calculate difference between dates and times - display as percent elapsed

    Attach a sample workbook (not a picture). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: Calculate difference between dates and times - display as percent elapsed

    My first thought is why are you converting good date/time serial numbers to text? I think this will be easier if you don't convert to text, but leave the values as date/time serial numbers. I would probably do something =J12-I12, then format as "dd hh:mm" which will display as 3 02:30 (meaning 3 days, 2 hours, 30 minutes). If you go through the instructions for building custom number/date/time formats, there are other ways to display the result as well https://support.office.com/en-us/art...2-09fab54be7f4

    Then, to get percentage time elapsed, you simply need to divide the elapsed time [=NOW()-start date/time)] by the total time (assume this is the J12-I12 calculation) to give =(NOW()-I12)/(J12-I12) or =(NOW()-I12)/(cell containing above calculation) formatted as per cent.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    02-20-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    7

    Re: Calculate difference between dates and times - display as percent elapsed

    Thanks for the help so far. I have it working better now, but I still need to simplify my formulas. The “Percent complete” seems to be working, although when I expand the table, sometimes that calculation works, sometimes it doesn’t. Sheet has been uploaded, any ideas here?
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: Calculate difference between dates and times - display as percent elapsed

    How much of this is now the "percent complete" calculation, and how much is the complex IF() logic that decides when to perform the "percent complete" calculation? It also might help to explain which of the sample calculations included in your latest file are incorrect.

    The only calculation that looks wrong to me is the one in row 15 where it is calculating 0%. Using the Evaluate Formula tool (https://support.office.com/en-us/art...6-a70aa409b8a7 ), I see that this result is mainly because the IF() logic sees that B15 is not equal to "started", so it chooses not to even perform the "percent complete" calculation. If I set B15 to "started", then the result seems correct.

    In short, it seems to me that the percent complete calculation is correct. I am not sure I understand the full logic you are trying to implement that chooses when to perform the percent complete calculation, but it looks to me like the error is in that decision logic. Is my analysis correct? Can you explain exactly how you want to decide when to perform the percent complete calculation? Am I missing something else?

  6. #6
    Registered User
    Join Date
    02-20-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    7

    Re: Calculate difference between dates and times - display as percent elapsed

    The sheet works as follows:

    If “B” = “Not Started” or “Cancelled”, set % Complete to 0%.
    If “B” = “Completed”, set % Complete to 100%.
    If “B” = “Started”, calculate % Complete based on today’s date/time versus end date/time.
    The other “IF” statements are error control and automation. I.e.: If the dates are reversed or missing, etc., display text in the cell. I am going to simplify the formulas and combine the “AND” and “OR” statements after I am done testing and troubleshooting.

    When I use the first row, it always calculates. When I add a new row to the table, the % Complete doesn’t always work.

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,535

    Re: Calculate difference between dates and times - display as percent elapsed

    I believe the reason that you encountered the issue "When I use the first row, it always calculates. When I add a new row to the table, the % Complete doesn’t always work" is due to some of the structured references not being targeted to the specific row. See if this helps:
    1) Select cell k12,
    2) Paste the following formula into the formula bar:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3) Drag the fill handle down to cell K15.
    If this doesn't resolve the issue please upload a sample showing the errant calculation, and of course tell us the correct/expected value.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Calculate difference between two dates and times in "days, hrs, mins
    By Rajatka in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-22-2013, 03:41 PM
  2. [SOLVED] How do you calculate elapsed time in hours between times on different dates?
    By RPeruzzi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-10-2013, 01:16 PM
  3. [SOLVED] Date format problem using a formula in VBA to calculate difference between times and dates
    By alicebrewer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2012, 03:13 AM
  4. Need to Calculate difference between 2 dates with times
    By KeithMark63 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-26-2012, 03:06 PM
  5. Replies: 2
    Last Post: 02-25-2006, 12:20 PM
  6. calculate elapsed time between dates and times
    By Jenna in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2006, 12:45 PM
  7. [SOLVED] how do I calculate difference between two dates and times
    By PatCN in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2005, 12:20 PM
  8. Replies: 6
    Last Post: 03-25-2005, 03:06 AM

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