+ Reply to Thread
Results 1 to 9 of 9

Change text to date format and use if statement to add year.

  1. #1
    Registered User
    Join Date
    11-24-2012
    Location
    Illinois, USA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Change text to date format and use if statement to add year.

    I have some data in the format below and would like to change it to date fromat for calculation purposes:

    F15 - Oct
    F15 - Feb
    F15 - Oct
    F15 - April
    F15 - Oct
    F15 - Nov

    I would like to change the text above to date format, however it needs to be 2014 if the months are F15 - May thru December and 2015 if it is F15 January thru April. Thus, F15 Oct should read Oct-14 and F15 - Jan would read Jan - 15. I used the formula =Right(A2, LEN(A2)-3), to remove the F15, however can't seem to combine it with an if statement to create the date as It doesn't work or I get an error.

    Thanks.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Change text to date format and use if statement to add year.

    The following formula seems to work. It's long because the primary lookup is done twice - first to determine the year based on the month, and second to re-calculate the month for the DATE function. If you put that lookup in its own cell as a helper, the DATE function would be much shorter. (But would use two cells, not one.)

    Be sure your month abbreviations are as I have done below. (Or adjust the abbreviations in the formula to match what you're using.) Based on your example, months with up to five letters were spelled out, otherwise they were shortened to three characters.

    Finally, format the formula cells as Custom using mmm-yy.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Paul; 07-31-2014 at 06:02 PM.

  3. #3
    Registered User
    Join Date
    11-24-2012
    Location
    Illinois, USA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Change text to date format and use if statement to add year.

    Thanks for the assistance

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Change text to date format and use if statement to add year.

    Or this

    =VALUE(IF(MONTH(1&REPLACE(A1,1,6,""))<=4,1&REPLACE(A1,1,6,"")&2015,1&REPLACE(A1,1,6,"")&2014))

    A
    B
    1
    F15 - Oct
    10/1/2014
    2
    F15 - Feb
    2/1/2015
    3
    F15 - Oct
    10/1/2014
    4
    F15 - April
    4/1/2015
    5
    F15 - Oct
    10/1/2014
    6
    F15 - Nov
    11/1/2014
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Change text to date format and use if statement to add year.

    Ahh, I've seen that 1&MONTH() before and typically forget to use it!

    Good work!

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Change text to date format and use if statement to add year.

    Quote Originally Posted by Paul View Post
    Ahh, I've seen that 1&MONTH() before and typically forget to use it!

    Good work!
    Thank you Paul, but why did you give me negative points for???

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Change text to date format and use if statement to add year.

    I gave you negative points??? Sheesh, must have hit the wrong button. Sorry about that, we'll get it corrected.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change text to date format and use if statement to add year.

    All fixed.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Change text to date format and use if statement to add year.

    Quote Originally Posted by JBeaucaire View Post
    All fixed.
    Thank you Jerry

+ 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] Plotting Year wise maximum value & occurance date - the input date is in text format.
    By thilag in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-08-2014, 06:34 AM
  2. Excel:How change the textbox format from text to date format?
    By inpetto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2013, 08:23 AM
  3. Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  4. [SOLVED] Use TEXT function as Criteria on Sumifs to convert month/year to date format
    By chico.corrales in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-08-2012, 07:49 PM
  5. change date format into text format.
    By adsxvii in forum Excel General
    Replies: 1
    Last Post: 03-22-2007, 02:07 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