+ Reply to Thread
Results 1 to 8 of 8

How to extract date from middle of text string and add one month to the date.

  1. #1
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    How to extract date from middle of text string and add one month to the date.

    Hi excel forum,
    I would like to take the month and year that is listed in the last 6 characters of the strings in column A and add one month to them.
    My desired result would be, e.g. for A2, "Monthly ISEA Progress Report - Oct 21" -> "Nov 21"
    For extra context, there is not always a " - " before the Date so using the function: =RIGHT(B5,LEN(B5)-FIND(" - ",B5))
    will not work for all cases.

    Objective 1:
    What I have been trying to achieve is adding a month to the date using the DATE function of:
    A2 = Monthly ISEA Progress Report - Oct 21
    =TEXT(DATE(RIGHT(A2,2),RIGHT(A2,6)-RIGHT(A2,2),),"MMM YY")
    But this does not work as Excel does not recognise this as a date.
    RIGHT(A2,2) = 21, RIGHT(A2,6) = Oct 21
    How do I extract just the "Oct" part of the string, given that:
    1. There is not always a " - " preceding the date.
    2. There is ALWAYS 6 characters from the right to include the whole date as a consistency.

    Objective 2:
    Once this month has been extracted, to be able to put it into the form of =TEXT(DATE(YEAR, MONTH,),"MMM YY") but with the Month (+1)

    If his doesn't make sense please let me know! Sheet Attached!
    Last edited by JulianS96; 09-02-2021 at 06:23 AM.

  2. #2
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,085

    Re: How to extract date from middle of text string and add one month to the date.

    in B2 with this:
    Please Login or Register  to view this content.
    in E2:
    Please Login or Register  to view this content.
    in F2
    Please Login or Register  to view this content.
    custom format cell E2 with this:
    Please Login or Register  to view this content.
    custom format cell F2
    Please Login or Register  to view this content.
    select B2,E2,F2, and drag down
    Last edited by janmorris; 09-02-2021 at 06:49 AM.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,812

    Re: How to extract date from middle of text string and add one month to the date.

    You can use this formula to give you the next month:

    =TEXT(EOMONTH(DATEVALUE(1&RIGHT($A2,6)),0)+1,"mmm-yy")

    Copy down as required.

    Hope this helps.

    Pete

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: How to extract date from middle of text string and add one month to the date.

    Try this:

    =TEXT(EDATE("1"&RIGHT(A2,6),1),"MMM-YY")

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,812

    Re: How to extract date from middle of text string and add one month to the date.

    If you want the month as a text value you can do this:

    =TEXT(DATEVALUE(1&RIGHT($A2,6)),"mmm")

    and the next month and year can be simplified from my earlier formula by doing this:

    =TEXT(DATEVALUE(1&RIGHT($A2,6))+32,"mmm-yy")

    Hope this helps.

    Pete

  6. #6
    Forum Contributor
    Join Date
    04-15-2013
    Location
    Singapore, Melbourne
    MS-Off Ver
    Office 365
    Posts
    167

    Re: How to extract date from middle of text string and add one month to the date.

    try this formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    set cells format as "MMM-YY"
    Row row row your boat
    Gently down the stream

  7. #7
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    Re: How to extract date from middle of text string and add one month to the date.

    Quote Originally Posted by Pete_UK View Post
    You can use this formula to give you the next month:

    =TEXT(EOMONTH(DATEVALUE(1&RIGHT($A2,6)),0)+1,"mmm-yy")

    Copy down as required.

    Hope this helps.

    Pete
    Quote Originally Posted by Phuocam View Post
    Try this:

    =TEXT(EDATE("1"&RIGHT(A2,6),1),"MMM-YY")
    both of these worked really well thank you!

    Would you be able to explain what the function of the "1&RIGHT" part is? Why is there a 1 there, what does it do?
    EDIT: I see what it does, it adds on 1 to the date, so that the date is a full date e.g. 1May 22, then the other 1 adds one to the month as required, thanks!
    Last edited by JulianS96; 09-02-2021 at 07:01 AM.

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,812

    Re: How to extract date from middle of text string and add one month to the date.

    Glad to help - thanks for the rep.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to Extract Date from the middle of the text
    By Hikari in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-25-2021, 11:04 PM
  2. Extract date from text string
    By Musciak in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-09-2019, 08:01 AM
  3. [SOLVED] Extract date and time from text string
    By iantix in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-14-2019, 10:30 AM
  4. Extract string of text in the middle of 2 delimiters
    By MoldyBread in forum Excel General
    Replies: 3
    Last Post: 05-07-2018, 07:21 AM
  5. extract a date from a text string
    By theobrandt in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-02-2016, 08:30 AM
  6. [SOLVED] Extract Text from String then Convert to a Date (Month/Year)
    By sgrey24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2013, 06:11 PM
  7. Extract text from the middle of a string for concatenation
    By christopherp in forum Excel General
    Replies: 1
    Last Post: 05-16-2011, 08:55 AM

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