+ Reply to Thread
Results 1 to 11 of 11

Subtract 15minutes from start time in a time range

  1. #1
    Registered User
    Join Date
    06-06-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    4

    Subtract 15minutes from start time in a time range

    Hi,

    I have an excel column that is in general form with time ranges (IE. 8:30AM-12:30PM, 9:15AM-11:15AM)
    I need a separate column that has this time range with a 15minute sooner start time but same end time (IE. 8:30AM-12:30PM is reported as 8:15AM-12:30PM).
    Is there a formula that can pull this in without me adding extra columns or forcing manual adjustments? I can trim out 8:30 but seem to get stuck subtracting 15minutes and adding back the end time. I have almost 200 time range combinations to adjust...

    Any help would be appreciated. thank you!

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Subtract 15minutes from start time in a time range

    Quote Originally Posted by JMS727 View Post
    Is there a formula that can pull this in without me adding extra columns or forcing manual adjustments?
    No, if you want to use a formula then it must be entered in another cell.

    If your time ranges were in 2 cells like this:

    A1 = start time 8:30 AM (as a true Excel time value)
    B1 = end time 12:30 PM (as a true Excel time value)

    Then you could do it without a formula.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    06-06-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Subtract 15minutes from start time in a time range

    Unfortunately, the data for the time range has to be in the same column for both instances because it is imported into a separate web displaying database. I am trying to avoid extra formating in columns that require being hidden.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Subtract 15minutes from start time in a time range

    Maybe someone (not me!) can do this with a macro?

    If you don't get a useable solution after a reasonable amount of time (whatever that is?) try starting a new thread in the VBA programming forum:

    http://www.excelforum.com/excel-programming-vba-macros/

  5. #5
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Subtract 15minutes from start time in a time range

    --edit--

    does the attached file work? this is the formula, see the uploaded example for the context :D

    =TEXT((LEFT(C3,FIND("M",C3,1)-2)-15/(24*60)),"HH:MM") & RIGHT(C3,LEN(C3)-FIND("M",C3,1)+2)
    Attached Files Attached Files
    Last edited by GeneralDisarray; 06-06-2013 at 11:27 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  6. #6
    Registered User
    Join Date
    06-06-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Subtract 15minutes from start time in a time range

    Oh you are awesome thankyou!! It is superduper close! This is the result....the ones that fall on the hour are funky. Suggestions?
    1:45PM-4:45PM 01:30PM-4:45PM
    1:00PM-4:00PM 00:45PM-4:00PM
    1:45PM-4:45PM 01:30PM-4:45PM
    1:00PM-4:00PM 00:45PM-4:00PM
    1:45PM-4:45PM 01:30PM-4:45PM
    8:30AM-11:30AM 08:15AM-11:30AM
    9:15AM-12:15PM 09:00AM-12:15PM
    8:30AM-11:30AM 08:15AM-11:30AM
    9:30AM-12:30PM 09:15AM-12:30PM
    1:00PM-4:00PM 00:45PM-4:00PM
    1:00PM-4:00PM 00:45PM-4:00PM

  7. #7
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Subtract 15minutes from start time in a time range

    darn, it's the PM thing. will get back to you

  8. #8
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Subtract 15minutes from start time in a time range

    ok, got it the formula becomes this:

    =REPLACE(TEXT(IFERROR(LEFT(C3,FIND("M",C3,1)-2)+CHOOSE((AND(FIND("-",C3,1)<FIND("PM",C3,1),LEFT(C3,2)<>"12"))*1 + 1,-15/(24*60),0.5-15/(24*60)),LEFT(C3,FIND("M",C3,1)-2)-15/(24*60)),"hh:mm AM/PM") & RIGHT(C3,LEN(C3)-FIND("-",C3,1)+1),6,1,"")


    dang. got kinda long :D and you probably don't need it anymore, but for the fun of doing it ... it be done
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-06-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Subtract 15minutes from start time in a time range

    So close again!! I really appreciate your help!
    Apparently, it is still flipping the AM versus PM....even in your example it takes 1:45PM and makes it 1:30AM.
    I manually changed all of my excel, but if you can figure out how to get the correct AM/PM switch, I will need to do this again in August (its a twice/year deal).

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Subtract 15minutes from start time in a time range

    Hmmm...

    I thought you didn't want to use a formula in another cell?

  11. #11
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Subtract 15minutes from start time in a time range

    ok, this is pretty ugly. Noon and Midnight were and pain in the butt, as was the 12 hour clock. Using a 24 hour clock would be much easier.. but i think this is it.

    =REPLACE(TEXT(IFERROR(LEFT(C18,FIND("M",C18,1)-2)+CHOOSE((LEFT(C18,7)="12:00AM")*2+(LEFT(C18,7)="12:00PM")*2+(FIND("-",C18,1)<FIND("PM",C18,1))*1 + 1,0.5-15/(24*60),-15/(24*60),-15/(24*60),0.5-15/(24*60)),LEFT(C18,FIND("M",C18,1)-2)-15/(24*60)),"hh:mm AM/PM") & RIGHT(C18,LEN(C18)-FIND("-",C18,1)+1),6,1,"")
    Attached Files Attached Files
    Last edited by GeneralDisarray; 06-07-2013 at 11:08 AM.

+ 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