+ Reply to Thread
Results 1 to 5 of 5

How to extract year and month from a date and combine them into a text

  1. #1
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    How to extract year and month from a date and combine them into a text

    Hi everyone,

    I have tried to extract year and month and combine them. For a date such as 31/05/2017, I want to get the output as 2017_05. How can do that?

    Thank you.

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to extract year and month from a date and combine them into a text

    With the date in A1, try

    =YEAR(A1)&"_"&MONTH(A1)

    or

    =TEXT(A1,"yyyy\_mm")

    This will change the date to Text format.

    You can also change the formatting of A1 to Custom yyyy\_mm and keep the value as an Excel recognized date.
    Last edited by 63falcondude; 06-02-2017 at 08:58 AM.

  3. #3
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: How to extract year and month from a date and combine them into a text

    Sorry, I need VBA version. My mistake. I should have put this message in the VBA section.

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

    Re: How to extract year and month from a date and combine them into a text

    MDate = Format(Mydate, "yyyy\_mm")

  5. #5
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: How to extract year and month from a date and combine them into a text

    Thank you so much, Phuocam. It is very useful.

+ 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] Extract Year, Month, Day from date
    By stoicy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-28-2016, 11:48 PM
  2. Extract Year, Month, Day from date
    By stoicy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2016, 01:41 PM
  3. [SOLVED] Extract 2 corresponding fields by Date/Month/Year selection
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-01-2015, 08:31 AM
  4. [SOLVED] Extract Day, Month and Year from a text box (user input) date value
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-01-2014, 10:40 PM
  5. [SOLVED] Combine date (month) and text and still be able to add a month to next column
    By kinscy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-20-2014, 12:34 AM
  6. [SOLVED] Extract Year or Month only from a cell with date and time
    By djaurit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2013, 04:03 PM
  7. [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

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