+ Reply to Thread
Results 1 to 9 of 9

Finding the difference between two dates and times

  1. #1
    Registered User
    Join Date
    02-14-2014
    Location
    US
    MS-Off Ver
    Excel 2010/13
    Posts
    3

    Finding the difference between two dates and times

    Hello Everyone,

    I am having difficulty finding the difference between two times and dates in Excel. I have researched this on Google and tried several formulas but none have worked for me. The format the data is currently in can be seen below:

    A1: 1/3/2014 11:00:02.230 B1: 2/7/2014 08:42:37.637
    A2: 2/12/2014 07:51:58.663 B2: 2/13/2014 05:36:31.893

    (Note all times are military time format)

    I want to display the difference in C1 in a format along the lines of "dd hh:mm". The data for seconds and fractions of a second is included in the source data but is not needed in the final results.

    If the date and time falls on the same day, I have no trouble doing a simple "B3-A3" to determine the answer. For example:

    A3: 2/5/2014 09:56:06.273 B3: 2/5/2014 10:39:51.34

    Gives me an answer of: 0:43

    Trying to do the same for A1 and B1 gives me this: "03 21:42" when I format it to "dd hh:mm".

    Is there a formula that would give me the correct answer in both of these cases?

    Thanks everyone for your help!
    Attached Files Attached Files
    Last edited by Harper95th; 02-14-2014 at 11:42 AM.

  2. #2
    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: Finding the difference between two dates and times

    Maybe this one

    =CONCATENATE(TEXT(FLOOR(B1-A1,1),"@")," Days",TEXT(B1-A1," h:mm:ss"))

    A
    B
    C
    1
    1/3/2014 11:00:02.230
    2/7/2014 8:42:37.637
    34 Days 21:42:35
    2
    2/12/2014 7:51:58.663
    2/13/2014 5:36:31.893
    0 Days 21:44:33
    3
    2/5/2014 9:56:06.273
    2/5/2014 10:39:51.340
    0 Days 0:43:45
    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

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Finding the difference between two dates and times

    Another approach that gives the same results:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Finding the difference between two dates and times

    The reason for the problem when using dd:hh:mm format is that "dd" actually shows "day of month" not elapsed days so when you get 3 for your example that's because the 34 days elapsed is converted to a date - 3rd Feb 1900 and dd returns the "day" part of that date, i.e. 3

    You can shorten 6StringJazzer's formula a little - MOD function isn't required

    =INT(B1-A1)&" " &TEXT(B1-A1,"hh:mm")
    Audere est facere

  5. #5
    Registered User
    Join Date
    02-14-2014
    Location
    US
    MS-Off Ver
    Excel 2010/13
    Posts
    3

    Re: Finding the difference between two dates and times

    Huge thanks to all three of you! I really appreciate the help. Each of those formulas worked great.

    AlKey, I understand your formula except for the "@" piece. Can you explain what that is doing?

  6. #6
    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: Finding the difference between two dates and times

    Quote Originally Posted by Harper95th View Post
    Huge thanks to all three of you! I really appreciate the help. Each of those formulas worked great.

    AlKey, I understand your formula except for the "@" piece. Can you explain what that is doing?
    Used with TEXT function to format as text.

  7. #7
    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: Finding the difference between two dates and times

    Thank you for your feedback!

  8. #8
    Registered User
    Join Date
    02-14-2014
    Location
    US
    MS-Off Ver
    Excel 2010/13
    Posts
    3

    Re: Finding the difference between two dates and times

    You're welcome! Thanks again to everyone for the help!

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Finding the difference between two dates and times

    You're welcome! Thanks for the rep, and thanks for marking your thread 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. 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
  2. [SOLVED] Difference in dates calculations except between certain times.
    By Steve Hud in forum Excel General
    Replies: 1
    Last Post: 01-13-2006, 09:15 AM
  3. [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
  4. [SOLVED] Difference between 2 times and dates
    By Stefan Buijs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2005, 05:19 PM
  5. [SOLVED] Difference between 2 times and dates
    By Stefan Buijs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-26-2005, 05:15 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