+ Reply to Thread
Results 1 to 5 of 5

Substracting dates/times formula needed

  1. #1
    Registered User
    Join Date
    11-06-2003
    MS-Off Ver
    2013
    Posts
    75

    Substracting dates/times formula needed

    I saw a post @ http://www.excelforum.com/excel-gene...and-times.html that gave a formula for subtracting two dates/times. But when I try the formula I get an error of #VALUE!

    The formula that was given follows:
    =DAY(B1-A1)&" days "&HOUR(B1-A1-DAY(B1-A1))&" hours "&MINUTE(B1-A1-DAY(B1-A1))&" minutes "&SECOND(B1-A1-DAY(B1-A1))&" seconds "

    Why am I getting an error message? My data is in A1 (3/14/15 8:00 AM) and in B1 (3/16/15 22:43 PM).


    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Substracting dates/times formula needed

    In B1, try this instead:

    Please Login or Register  to view this content.
    Military time doesn't have AM/PM associated with it in Excel, and that value seems to be throwing off the calculations.
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Substracting dates/times formula needed

    not sure but try this:

    =IF(INT(B1)-INT(A1)=0,"",INT(B1)-INT(A1)&" days ")&IF(HOUR((B1-INT(B1))-(A1-INT(A1)))=0,"",HOUR((B1-INT(B1))-(A1-INT(A1)))&" hours ")&IF(MINUTE((B1-INT(B1))-(A1-INT(A1)))=0,"",MINUTE((B1-INT(B1))-(A1-INT(A1)))&" minutes ")&IF(SECOND((B1-INT(B1))-(A1-INT(A1)))=0,"",SECOND((B1-INT(B1))-(A1-INT(A1)))&" second")

    cheers

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Substracting dates/times formula needed

    Actually you don't need such a big formula for this. All you need: =B1-A1

    then format cell as Custom, d " Days", h " Hours", m " Minutes", s "Seconds"

    Row\Col
    A
    B
    C
    1
    3/14/2015 8:00
    3/16/2015
    2 Days, 14 Hours, 43 Minutes, 0 Seconds
    Last edited by AlKey; 03-17-2015 at 02:20 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Registered User
    Join Date
    11-06-2003
    MS-Off Ver
    2013
    Posts
    75

    Re: Substracting dates/times formula needed

    Thank you all. The military time was what was giving me the issue. So even the simply formula worked. But ended up using the original formula from olechippy since it better fit my needs.

+ 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 needed to display Break and Lunch Times from another sheet
    By playaller in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2013, 12:48 PM
  2. Substracting times in [h]:mm format
    By wlan in forum Excel General
    Replies: 2
    Last Post: 05-29-2011, 01:40 PM
  3. Substracting dates and times
    By pietjeplezier in forum Excel General
    Replies: 3
    Last Post: 03-02-2007, 07:48 PM
  4. Substracting Dates.
    By exsam21 in forum Excel General
    Replies: 3
    Last Post: 01-20-2006, 03:20 PM
  5. Dates and Times formula
    By eg985 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-11-2005, 07:43 PM

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