+ Reply to Thread
Results 1 to 6 of 6

Subtracting Dates/Times

  1. #1
    Registered User
    Join Date
    05-26-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    33

    Subtracting Dates/Times

    Hi again all,

    I have 5 columns:


    A1=start date

    B1=start time

    C1=end date

    D1=end time

    E1=the difference in hours/minutes


    Now, I need to calculate, in hours/minutes ("32:06", etc.), the time that has elapsed between A1/B1 & C1/D1 --- i.e., if A1 = "11/08/11" and B1 = "18:30" and C1 = "11/11/11" and D1 = "18:35", then I need "72:05" to appear in E1 (also need intra-day as well as inter-day times).


    Thanx a lot,
    Frith

    PS - The spreadsheet times are displayed in military format ("22:35"), if that matters at all.

    Cross-Post: http://www.mrexcel.com/forum/showthr...70#post2927470
    Last edited by frith; 11-11-2011 at 07:49 PM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Subtracting Dates/Times

    =INT((C1+D1)-(A1+B1))*24&":"&TEXT((((C1+D1)-(A1+B1))-INT((C1+D1)-(A1+B1)))*24*60,"00")

    Pauley

  3. #3
    Registered User
    Join Date
    05-26-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Subtracting Dates/Times

    Quote Originally Posted by Pauleyb View Post
    =INT((C1+D1)-(A1+B1))*24&":"&TEXT((((C1+D1)-(A1+B1))-INT((C1+D1)-(A1+B1)))*24*60,"00")

    Pauley
    Thanks, but do I need to "format" anything in E1, as with my existing data all I get there is "-980544:9"

    Frith

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Subtracting Dates/Times

    If your values are not formatted as text, I would think you are looking for
    (C1+D1)-(A1+B1) and formatted as Custom [h]:mm
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Subtracting Dates/Times

    Formatting is involved. ChemistB's solution is much cleaner. I saw the h:mm format did not work, but did not get to the [h]:mm format.

    Attached is a worksheet to show proof of concept. Format your sheet to match.

    Pauley
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-26-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Subtracting Dates/Times

    Quote Originally Posted by Pauleyb View Post
    Formatting is involved. ChemistB's solution is much cleaner. I saw the h:mm format did not work, but did not get to the [h]:mm format.

    Attached is a worksheet to show proof of concept. Format your sheet to match.

    Pauley

    Thanx guys... Turned out my existing VBA was screwing things up!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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