+ Reply to Thread
Results 1 to 3 of 3

Thread: Difference between two dates

  1. #1
    Valued Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    403

    Difference between two dates

    HI,

    I want the user to be able to type times without the :

    In A1 is custom formatted as: 00\:00 and when typing 1234 it displays 12:34

    So far so good especially because I don't want to use helper/adjacent cells.

    Cell B1 is formatted as hh:mm and has 13:15 in it.

    I want to calculate the time difference between A2 and A1 (expected 00:41)

    =B1-A1 in cell C1 (formatted as hh:mm) won't give the correct answer - so I tried:

    =INT(B1/100)/24+MOD(B1,100)/1440-INT(A1/100)/24-MOD(A1,100)/1440

    which is OK but I wonder if there is any shorter formula to calculate the difference ?

    Thanks, Elm
    Last edited by ElmerS; 05-08-2010 at 06:29 AM.

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Difference between two dates

    Use the same principles as per the Custom Format

    C1: =MOD(B1-TEXT(A1;"00\:00");1)

  3. #3
    Valued Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    403

    Re: Difference between two dates

    Thanks. Elm

+ 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.2.0