+ Reply to Thread
Results 1 to 12 of 12

time minus time

  1. #1
    Registered User
    Join Date
    04-25-2007
    Posts
    24

    time minus time

    I have col A as a date and time in the following format

    2010.03.15 03:50

    I have col B as a date and time in the following format

    2010.03.15 10:22

    I would like col C to be the difference in time (in minutes) between the 2 columns.

    Col B is always later than Col A

    How can I achieve this?


    Thanks

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: time minus time

    Hi,

    Please Login or Register  to view this content.
    as long as actual inputs are formatted as date ...

    HTH

  3. #3
    Registered User
    Join Date
    04-25-2007
    Posts
    24

    Re: time minus time

    If I use a1-b1 I get (value#)
    The dates are displayed exactly as I have shown and their are thousands of them.
    How can I get a number like this to be understood my Excel to be a Date?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: time minus time

    If data was entered that way, and depending on your regional settings, Excel doesn't recognize it as a date, so it's just text.

    (If it were entered as a date and time, it could FORMATTED as yyyy.mm.dd hh:mm to appear that way.)

    If you have to do this routinely, I'd suggest a VBA solution.

    If it's a one-off, I'd do it the quickest way I can think of without thinking much:
    • Do Data > Text to columns, Delimited, use Space as a delimiter to separate the date and time (need a blank column to right to receive the time)
    • Select the first column again, Data > Text to columns, Next, Next, select Date and DMY from dropdown, Finish (no extra column needed; works in situ)
    • Then add those two columns together, copy and replace with values, delete the now-unneeded columns, and proceed on course.
    It takes much longer to read this than to do it.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: time minus time

    Or if amending originals is not viable you might perhaps get away with:

    C1: =SUBSTITUTE(B1,".","-")-SUBSTITUTE(A1,".","-")
    C1 format as [mm]:ss
    copied down
    Last edited by DonkeyOte; 04-03-2010 at 12:07 PM. Reason: missing "T" in the first SUBSTITUTE call as outlined by JR in latter post - corrected to avoid confusion for future ref.

  6. #6
    Registered User
    Join Date
    04-25-2007
    Posts
    24

    Re: time minus time

    DonkeyOte

    Thanks for your reply

    I am sorry to say that I don't understand this instruction.

    Am I suppose to copy this into C1? What are the quote signs meant to designate?

    Thanks again

  7. #7
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: time minus time

    Assuming you have dates in A1 and B1 then yes you would just put the formula into C1 otherwise you will need to adjust the cell references. The "" around something designate it as a text string.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  8. #8
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: time minus time

    Hi,

    DonkeyOte is proposing the use of the function Substitute() ... since your cells are formatted as text and are not formatted as dates ...

    see attached

    HTH
    Attached Files Attached Files
    Last edited by JeanRage; 04-03-2010 at 11:23 AM.

  9. #9
    Registered User
    Join Date
    04-25-2007
    Posts
    24

    Re: time minus time

    DonkeyOte

    Thanks for your reply

    I am sorry to say that I don't understand this instruction.

    Am I suppose to copy this into C1? What are the quote signs meant to designate?

    Thanks again

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: time minus time

    No need to repeat your post - see JR's prior attachement which illustrates the concept.

    Bsaed on your prior posts the string format of: yyyy.mm.dd hh:mm is not valid for coercion - you need to replace the period delimiters with a hyphen ie yyyy-mm-dd hh:mm at which point the string can be coerced to true datetime value (date.time).
    The subtraction of one string from the other coerces both strings simultaneously.

  11. #11
    Registered User
    Join Date
    04-25-2007
    Posts
    24

    Re: time minus time

    I am sorry about my repeated posts. I did not do it intentionally.

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: time minus time

    Not a problem - is your issue resolved or do you still require assistance ?

+ 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