+ Reply to Thread
Results 1 to 8 of 8

Convert YYYY to text, or YY to text

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Convert YYYY to text, or YY to text

    Anyone know a formula that can take a 'mm/yy' or 'mm/yyyy' cell and write the century and year out in longhand?

    So yyyy=1900 would be "Nineteen hundred years ", yyyy=1901 would be "Nineteen hundred and one years", "yy" =18 would be "Two thousand and eighteen years", and so one.

    Tried creating a formula that "splits" the number into two, with the first step looking at the LH pair (e.g. 19 or 20) if they exist, then convert the RH pair (e.g. 03, 15,29,31 etc)

    Look forward to pointers

    Ochimus

  2. #2
    Forum Contributor
    Join Date
    03-12-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    421

    Re: Convert YYYY to text, or YY to text

    Maybe try this:

    Please Login or Register  to view this content.
    Last edited by fredfarmer; 05-07-2019 at 03:45 PM.

  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,731

    Re: Convert YYYY to text, or YY to text

    When you say a 'mm/yy' cell, or a 'mm/yyyy' cell, does the cell contain a date which is formatted to display either mm/yy or mm/yyyy, or does the cell contain a text value in one of those formats?

    If it is a date, then we can use the YEAR function to extract the year, but if it is a text value we would need to use RIGHT in conjunction with FIND("/" …

    Pete

  4. #4
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Convert YYYY to text, or YY to text

    Sorry for delayed reply, gents, been out of contact for few days!

    The cells are dates formatted to either a four digit or two digit year (checked by converting the cell to "comma style" format. Works perfectly).

    But YEAR does not deliver what I want. If A2 is 01/01/2019, and B2 "=YEAR(A2)", B2 will contain four numbers (2019).

    I want a formula in B2 that will see the year in the date "01/01/2019" in A2 and enter "Two thousand and nineteen years".

    Presumably it will have to identify the century first (e.g. 1999 would be "Nineteen hundred"), THEN identify the two final digits (99) and - as they are more than zero - add them as "and ninety nine years".)

    Ochimus
    Last edited by Ochimus; 05-09-2019 at 10:44 AM.

  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,731

    Re: Convert YYYY to text, or YY to text

    Do you want to see "nineteen hundred" if the century year is 19, or would "one thousand nine hundred" be acceptable?

    Pete

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

    Re: Convert YYYY to text, or YY to text

    Here's a formula that can do it, assuming your (proper) date is in A1, this can go in B1:

    =CHOOSE(INT(YEAR(A1)/1000),"One","Two")&" thousand "&IF(MID(YEAR(A1),2,1)="0","",CHOOSE(MID(YEAR(A1),2,1)*1,"one","two","three","four","five","six","seven","eight","nine")&" hundred")&" and "&IF(AND(MOD(YEAR(A1),100)>9,MOD(YEAR(A1),100)<20),CHOOSE(MOD(YEAR(A1),100)-9,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),IF(MID(YEAR(A1),3,1)="0",CHOOSE(MOD(YEAR(A1),100),"one","two","three","four","five","six","seven","eight","nine"),CHOOSE(MID(YEAR(A1),3,1)*1-1,"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")&IF(MID(YEAR(A1),4,1)="0",""," "&CHOOSE(MID(YEAR(A1),4,1)*1,"one","two","three","four","five","six","seven","eight","nine"))))

    Copy it down if needed.

    Hope this helps.

    Pete

  7. #7
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Convert YYYY to text, or YY to text

    Apologies to everyone for delay in acknowledging the responses, but been guest of the NHS for last few weeks!

    Now back, and using Peter's approach can mark this as "Solved"

    Ochimus

  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,731

    Re: Convert YYYY to text, or YY to text

    Thanks for the rep - I hope you are feeling much better now.

    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. Convert Date format from Text format reading m/d/yyyy to dd/mm/yyyy
    By bridge4444 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-23-2017, 11:22 PM
  2. [SOLVED] Convert NUMBER Series entered as TEXT To DATE FORMAT mm/dd/yyyy
    By jobie804 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-05-2014, 02:38 PM
  3. Convert dd/mm/yyyy DATE >> to mm/yyyy TEXT
    By Mr.X in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-05-2014, 10:59 PM
  4. [SOLVED] convert MM/DD/YYYY to DD/MM/YYYY while the data format is text
    By Vogelmann in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-18-2012, 02:43 PM
  5. Excel 2007 : Convert Text/Number Column into MM/DD/YYYY
    By ProjectMASE in forum Excel General
    Replies: 5
    Last Post: 06-21-2010, 05:14 PM
  6. hot to convert a date object into a text (format yyyy-mm-dd)
    By xianwinwin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2007, 12:07 PM
  7. Convert text to date dd/mm/yyyy hh:mm:ss
    By Scottish2 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-04-2007, 07:59 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