+ Reply to Thread
Results 1 to 8 of 8

How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm cell

  1. #1
    Registered User
    Join Date
    10-03-2023
    Location
    USA
    MS-Off Ver
    Office365
    Posts
    7

    How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm cell

    How do I properly use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm cells?

    Example I'm trying to achieve:
    Cell A1: 9/27/23 4:15 PM
    Cell B1: 9/27/23 4:27 PM
    Cell C1: =SUM(B1-A1) to show 00:12
    Cell D1: =IF(D1>00:15,NO,YES) to show YES

    I've been trying to throw different SUM formulas and custom formatting and this and that, but cannot for the life of me get it to work. I think Office365 web is partially the problem, but perhaps there is something at play.

    During the process of trial and error, I've managed to get outputs to show "-4325.4"2 type output or "#######" with no actual numbers. I tried formatting the cell various ways and can't get it to work. Please help.

    After getting the correct output going I'm going to throw an IF formula in D1 "=IF(C1>00:15,NO,YES)" to see what tickets are meeting SLA response times.

    Update: In the process of adding a sample file, I got =SUM and =SUMPRODUCT formulas to work in two of the cells as samples, but the math is incorrect. Looking forward to learn something about this situation. Thanks a bunch.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by J3RM; 10-03-2023 at 05:48 PM.

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

    Re: How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm

    The SUM() function is redundant in that formulation. You can just use =B1-A1 without the SUM() function.

    I see no reason why you should be getting an error value or no display based on your description. What do you see when you format as general?

    The usual problems:

    One or both are text strings and Excel is not converting the text to numbers correctly.
    B1 is smaller/earlier than A1, and Excel does not know how to display negative times (other spreadsheets are not limited in this way).
    The number format is set to show more information than can fit in the width of the column. Make sure to use a "short" number format like [hh]:mm

    If you can upload a sample file to the forum, we may be able to help in more detail.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm

    When I recreate your data and format the result as h:mm in customized I get the expected results. I suspect without seeing your actual file that your data in columns A & B are text formatted and not true date time.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    10-03-2023
    Location
    USA
    MS-Off Ver
    Office365
    Posts
    7

    Re: How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm

    Quote Originally Posted by MrShorty View Post
    The SUM() function is redundant in that formulation. You can just use =B1-A1 without the SUM() function.

    I see no reason why you should be getting an error value or no display based on your description. What do you see when you format as general?

    The usual problems:

    One or both are text strings and Excel is not converting the text to numbers correctly.
    B1 is smaller/earlier than A1, and Excel does not know how to display negative times (other spreadsheets are not limited in this way).
    The number format is set to show more information than can fit in the width of the column. Make sure to use a "short" number format like [hh]:mm

    If you can upload a sample file to the forum, we may be able to help in more detail.
    Quote Originally Posted by alansidman View Post
    When I recreate your data and format the result as h:mm in customized I get the expected results. I suspect without seeing your actual file that your data in columns A & B are text formatted and not true date time.


    Ok, I just added an update to the bottom of my original post, but also I just tried the =D6-C6 and the math is still incorrect. Sample sheet attached.

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

    Re: How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm

    E6 looks correct to me. When you subtract 8:20:01 PM from 8:42:00 PM, you get 0:21:59 hours:minutes:seconds. Excel does not round to the nearest minute when you format a time value to only show minutes, so 0:21:59 formatted as hh:mm correctly displays as 00:21.

    Do you need the calculation to round to the nearest minute? =MROUND(D6-C6,TIME(0,1,0))
    Last edited by MrShorty; 10-03-2023 at 07:02 PM.

  6. #6
    Registered User
    Join Date
    10-03-2023
    Location
    USA
    MS-Off Ver
    Office365
    Posts
    7

    Re: How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm

    Quote Originally Posted by MrShorty View Post
    The SUM() function is redundant in that formulation. You can just use =B1-A1 without the SUM() function.

    I see no reason why you should be getting an error value or no display based on your description. What do you see when you format as general?

    The usual problems:

    One or both are text strings and Excel is not converting the text to numbers correctly.
    B1 is smaller/earlier than A1, and Excel does not know how to display negative times (other spreadsheets are not limited in this way).
    The number format is set to show more information than can fit in the width of the column. Make sure to use a "short" number format like [hh]:mm

    If you can upload a sample file to the forum, we may be able to help in more detail.
    Quote Originally Posted by alansidman View Post
    When I recreate your data and format the result as h:mm in customized I get the expected results. I suspect without seeing your actual file that your data in columns A & B are text formatted and not true date time.
    Quote Originally Posted by MrShorty View Post
    E6 looks correct to me. When you subtract 8:20:01 PM from 8:42:00 PM, you get 0:21:59 hours:minutes:seconds. Excel does not round to the nearest minute when you format a time value to only show minutes, so 0:21:59 formatted as hh:mm correctly displays as 00:21.
    Book (1).xlsx
    Do you need the calculation to round to the nearest minute? =MROUND(D6-C6,TIME(0,1,0))
    Ok, I see now about the seconds. Formatting the date/time cells to show 00:00:00 it would indeed require rounding. After testing it and manually entering it I do see it works properly. =MROUND(D6-C6,TIME(0,1,0) does the subtraction and then rounding. Perfect.

    Follow up question:
    1) How would I get the =IF function to cooperate and populate in column F on the attached sample? I'm unable to get it to work ... =IF(E7>15,FALSE,TRUE) ... I tried =IF(E7>0:15,FALSE,TRUE), but that just throws an error.

    E.g. Ideally I would like it to say YES if we respond under 0:15. If it takes us longer than 0:15 it is NO.

    I've played around with the =IF function various ways and can't get it to work for me. They all just say TRUE or FALSE despite me adjusting. Cell E6 is 0:22 which is >15, so it should show as FALSE or NO, if a YES/NO output is an option. (I don't really need or want TRUE/FALSE)Book (1).xlsx
    Last edited by J3RM; 10-04-2023 at 09:45 AM.

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

    Re: How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm

    The conditional part of the function (E7>15) is comparing the actual value of E7 with the number 15. Note that the way the spreadsheets store date/time information, 15 means "15 days" or "15 Jan 1900," so your first comparison is asking if E7 is greater than 15 days or after 15 Jan 1900. All of the time values will be less than 1 day, so they will all be less than 15 days.

    Probably the most reliable way to enter a value that means "15 minutes" into a formula like this is to use the TIME() function. =IF(E7>TIME(0,15,0),...). The TIME() function will return a value between 0 and 1 that accurately represents the combination of hours, minutes, and seconds that you enter.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to use the SUM formula to subtract and calculate time elapsed from mm/dd/yy hh:mm

    Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. [SOLVED] Formula to calculate elapsed time between two dates/time in Google Sheets
    By bhenlee in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-12-2023, 05:13 AM
  2. [SOLVED] SUMPRODUCT Formula to Calculate Elapsed Time
    By sorensjp in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-27-2022, 10:59 AM
  3. Formula to Calculate Current Time Elapsed
    By kschmit1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-13-2017, 02:33 PM
  4. [SOLVED] How to subtract Time Values contained in Labels on a userform - Time Elapsed Live Clock
    By deadeye_draken in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-18-2017, 06:44 AM
  5. Replies: 2
    Last Post: 04-27-2011, 08:21 AM
  6. [SOLVED] Ref: Formula to calculate elapsed time between certain dates and t
    By DrBarqs in forum Excel General
    Replies: 2
    Last Post: 11-18-2005, 07:20 PM
  7. Replies: 6
    Last Post: 03-25-2005, 03:06 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