+ Reply to Thread
Results 1 to 4 of 4

Calculating the difference between cells

  1. #1
    SheriffCassidy
    Guest

    Calculating the difference between cells

    I'm new to functions and formulas - how do I create one to automatically
    update a cell so that it shows the difference between two cells that display
    times.

    For example, cell A1 contains 2:30pm and A2 contains 2:45pm - I want A3 to
    display the difference, regardless of whether it is a negative or postivie.
    In fact, I would prefer that it made no reference to whether it's a negative
    or not.

  2. #2
    Peo Sjoblom
    Guest

    Re: Calculating the difference between cells

    If you want negative time you have to change the date system to 1904 under
    tools>options>calculation

    Note that it will add 1462 days to any date, so if you use that you can
    convert back any altered dates by putting 1462 in an empty cell, copy it,
    paste special and select subtract

    otherwise you have to fake it

    =IF(B1>=A1,TEXT(B1-A1,"[h]:mm:ss"),TEXT(A1-B1,"-[h]:mm:ss"))

    --


    Regards,

    Peo Sjoblom


    "SheriffCassidy" <[email protected]> wrote in message
    news:[email protected]...
    > I'm new to functions and formulas - how do I create one to automatically
    > update a cell so that it shows the difference between two cells that
    > display
    > times.
    >
    > For example, cell A1 contains 2:30pm and A2 contains 2:45pm - I want A3 to
    > display the difference, regardless of whether it is a negative or
    > postivie.
    > In fact, I would prefer that it made no reference to whether it's a
    > negative
    > or not.




  3. #3
    Biff
    Guest

    Calculating the difference between cells

    Hi!

    Try this:

    =ABS(A2-A1)

    Format the cell as [h]:mm

    Biff

    >-----Original Message-----
    >I'm new to functions and formulas - how do I create one

    to automatically
    >update a cell so that it shows the difference between two

    cells that display
    >times.
    >
    >For example, cell A1 contains 2:30pm and A2 contains

    2:45pm - I want A3 to
    >display the difference, regardless of whether it is a

    negative or postivie.
    >In fact, I would prefer that it made no reference to

    whether it's a negative
    >or not.
    >.
    >


  4. #4
    Arvi Laanemets
    Guest

    Re: Calculating the difference between cells

    Hi

    Another situation is, when the time interval contains midnight, or even
    several days, like start time was 14:45 and end time was 14:30 in next day.
    When this is the case, either:
    1) Use datetime values instead of times, like A2=14.02.2005 14:45,
    A3=15.02.2005 14:30
    now you can calculate the difference as
    =A3-A2
    Depending on max interval length, format the cell with formula as "hh:mm" or
    "[h]:mm" or "[d] hh:mm"
    This works with time intervals of any length, but start time must always be
    the earlier one.

    2) With ordinary time values in source cells, like in your example,
    calculate the difference as:
    =A3-A2+(A3<A2)
    Format the cell with formula with any valid time format.
    This works, when the time intervals are always less than 24 hours. Again,
    start time must always be the earlier one.

    --
    When sending mail, use address arvil<at>tarkon.ee
    Arvi Laanemets


    "SheriffCassidy" <[email protected]> wrote in message
    news:[email protected]...
    > I'm new to functions and formulas - how do I create one to automatically
    > update a cell so that it shows the difference between two cells that

    display
    > times.
    >
    > For example, cell A1 contains 2:30pm and A2 contains 2:45pm - I want A3 to
    > display the difference, regardless of whether it is a negative or

    postivie.
    > In fact, I would prefer that it made no reference to whether it's a

    negative
    > or not.




+ 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