+ Reply to Thread
Results 1 to 3 of 3

Formula which adds :00 to a time interval taken from another cell

  1. #1
    Registered User
    Join Date
    04-30-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Formula which adds :00 to a time interval taken from another cell

    I have a long column of cells which all are in the form "1pm - 3pm Golf with John" or "11:30am - 12:30pm Meeting with Paul". I need to take these cells and make a new column of only the time intervals, ex. "1:00pm - 3:00 pm", "4:00pm - 5:30pm"
    While I've been able to display the times with

    =REPLACE(E2,FIND(" ",E2,FIND(" - ",E2,1)+3),100,"")

    which I know is hideous looking, I can't make the times display as ":00" if the time ends an hour, such as "1pm", "2pm", etc.
    I did succeed in displaying the first hour's minutes with (get ready)

    =IF(5=SEARCH("-",E2,1),LEFT(E2,1)&":00"&MID(REPLACE(E2,FIND(" ",E2,FIND(" - ",E2,1)+3),100,""),2,100),IF(6=SEARCH("-",E2,1),LEFT(E2,1)&":00"&MID(REPLACE(E2,FIND(" ",E2,FIND(" - ",E2,1)+3),100,""),2,100),REPLACE(E2,FIND(" ",E2,FIND(" - ",E2,1)+3),100,"")))

    and now I give up lol. Is this easy and I just don't know a formula for it? I'm an excel noobie, I learned all the formulas in there today, kinda making things up as I go along.

    Help is greatly appreciated! =)

  2. #2
    Registered User
    Join Date
    04-30-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Post Re: Formula which adds :00 to a time interval taken from another cell

    I DID IT. code below

    =IF(LEN(REPLACE(E2,FIND(" ",E2,1),100,""))=3,LEFT(REPLACE(E2,FIND(" ",E2,1),100,""),1)&":00"&RIGHT(REPLACE(E2,FIND(" ",E2,1),100,""),2),IF(LEN(REPLACE(E2,FIND(" ",E2,1),100,""))=4,LEFT(REPLACE(E2,FIND(" ",E2,1),100,""),2)&":00"&RIGHT(REPLACE(E2,FIND(" ",E2,1),100,""),2),REPLACE(E2,FIND(" ",E2,1),100,"")))&" - "&IF(LEN(REPLACE(RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),FIND(" ",RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),1),100,""))=3,LEFT(REPLACE(RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),FIND(" ",RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),1),100,""),1)&":00"&RIGHT(REPLACE(RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),FIND(" ",RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),1),100,""),2),IF(LEN(REPLACE(RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),FIND(" ",RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),1),100,""))=4,LEFT(REPLACE(RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),FIND(" ",RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),1),100,""),2)&":00"&RIGHT(REPLACE(RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),FIND(" ",RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),1),100,""),2),REPLACE(RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),FIND(" ",RIGHT(E2,LEN(E2)-LEN(REPLACE(E2,FIND(" ",E2,1)+1,100,""))-2),1),100,"")))

    there's proooobably a better way to do that. B)

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Formula which adds :00 to a time interval taken from another cell

    You know you can use Text To Columns to extract the time right?

+ 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